Sorry, I forgot to mention that every plots we display (every 1m30s) is displayed in the same HPlot canvas. Data is put in P1D objects and added to the first graph in a HPlot graph. Previous data is removed prior to adding.
In my HPlot wrapper, I have a font object that I use for every fonts needed by Graph:
Code:
public static final Font GRAPH_FONT = new Font(null, Font.PLAIN, 10);
At my display window initialization, I configure my HPlot correctly to match my needs. The internalPlotWindow object is my HPlot.
Code:
//Configure the display og the plot canvas.
this.getInternalPlotWindow().setAttResizableAll(false);
this.getInternalPlotWindow().setAxesRatioUse(false);
this.getInternalPlotWindow().setBox(false);
this.getInternalPlotWindow().setAutoRange(true);
this.getInternalPlotWindow().setGrid(true);
this.getInternalPlotWindow().setMarginSizeLeft(0.0);
this.getInternalPlotWindow().setMarginSizeTop(0.0);
this.getInternalPlotWindow().setMarginSizeRight(0.0);
this.getInternalPlotWindow().setMarginSizeBottom(0.0);
this.getInternalPlotWindow().setPenWidthAxis(1.0);
this.getInternalPlotWindow().setTicFont(GRAPH_FONT);
this.getInternalPlotWindow().setLegendFont(GRAPH_FONT);
this.getInternalPlotWindow().setTicsMirror(false);
this.getInternalPlotWindow().setTics(true);
this.getInternalPlotWindow().setAxisPenTicWidth(1);
this.getInternalPlotWindow().setNumberOfTics(true);
this.getInternalPlotWindow().setNumberOfTics(Axis.X_AXIS, 10);
this.getInternalPlotWindow().setNumberOfTics(Axis.Y_AXIS, 10);
//Add the listeners to the graph for display functions
this.getInternalPlotWindow().getJPlot().getGraph().addMouseWheelListener(this);
this.getInternalPlotWindow().getJPlot().getGraph().addMouseListener(this);
this.getInternalPlotWindow().getJPlot().getGraph().addMouseMotionListener(this);
this.getInternalPlotWindow().getJPlot().getGraph().addKeyListener(this);
this.getInternalPlotWindow().getJPlot().getGraph().setFocusable(true);
this.getInternalPlotWindow().getJPlot().getGraph().requestFocusInWindow();
this.getInternalPlotWindow().getJPlot().getGraph().addFocusListener(new FocusListener(){
public void focusGained(FocusEvent e) {}
public void focusLost(FocusEvent e) {
//internalPlotWindow.getJPlot().getGraph().requestFocusInWindow();
}
});
When I add a plot to the graph, I do things that way:
Code:
this.getInternalPlotWindow().draw(newItem.getPlot());//getPlot() returns a P1D object of 16384 data points
this.getInternalPlotWindow().setNameX(newItem.getCurrentEntry().getXunits().getUnits(), GRAPH_FONT);
this.getInternalPlotWindow().setNameY(newItem.getCurrentEntry().getYunits().getUnits(), GRAPH_FONT);
And when I need to remove 1 of them, I cal the clearData() function of HPlot, then re-call the draw(P1D) method for the remaining plots I need to plot.