package org.helioviewer.plugins.eveplugin.events.gui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.List;
import java.util.Map;

import org.helioviewer.base.logging.Log;
import org.helioviewer.plugins.eveplugin.base.Range;
import org.helioviewer.plugins.eveplugin.draw.DrawableElement;
import org.helioviewer.plugins.eveplugin.draw.DrawableElementType;
import org.helioviewer.plugins.eveplugin.draw.YAxisElement;
import org.helioviewer.plugins.eveplugin.events.model.EventModel;
import org.helioviewer.plugins.eveplugin.events.model.EventPlotConfiguration;
import org.helioviewer.plugins.eveplugin.events.model.EventTypePlotConfiguration;

public class EventPanel implements DrawableElement {

    public EventPanel() {

    }

    @Override
    public DrawableElementType getDrawableElementType() {
        return DrawableElementType.EVENT;
    }

    @Override
    public void draw(Graphics g, Rectangle graphArea) {
        long start = System.currentTimeMillis();
        Thread.dumpStack();
        if (EventModel.getSingletonInstance().isEventsVisible()) {
            EventTypePlotConfiguration etpc = EventModel.getSingletonInstance().getEventTypePlotConfiguration();
            Map<String, List<EventPlotConfiguration>> epcs = etpc.getEventPlotConfigurations();
            int eventTypeNr = 0;
            int previousLine = 0;
            for (String eventType : epcs.keySet()) {
                for (EventPlotConfiguration epc : epcs.get(eventType)) {
                    epc.draw(g, graphArea, etpc.getNrOfEventTypes(), eventTypeNr, etpc.getMaxLinesPerEventType().get(eventType).intValue(),
                            etpc.getTotalNrLines(), previousLine);
                }
                eventTypeNr++;
                previousLine += etpc.getMaxLinesPerEventType().get(eventType).intValue();
            }
        }
        Log.info("Run draw time: " + (System.currentTimeMillis() - start));
    }

    @Override
    public void setYAxisElement(YAxisElement yAxisElement) {
        // TODO Auto-generated method stub

    }

    @Override
    public YAxisElement getYAxisElement() {
        return new YAxisElement(new Range(0, 0), new Range(0, 0), "", 0, 0, Color.BLACK);
    }

    @Override
    public boolean hasElementsToDraw() {
        return !EventModel.getSingletonInstance().getEventTypePlotConfiguration().getEventPlotConfigurations().isEmpty();
    }
}

@@ -744,29 +744,172 @@
    p
-ublic EventPanel() %7B%0A
+rivate final YAxisElement yAxisElement;%0A%0A    public EventPanel() %7B%0A        yAxisElement = new YAxisElement(new Range(0, 0), new Range(0, 0), %22%22, 0, 0, Color.BLACK);
 %0A   
@@ -2301,21 +2301,17 @@
  return 
-new Y
+y
 AxisElem
@@ -2317,65 +2317,8 @@
 ment
-(new Range(0, 0), new Range(0, 0), %22%22, 0, 0, Color.BLACK)
 ;%0A  

Fix part of the problems with the y-axis