Package plotter.xy

Examples of plotter.xy.LinearXYAxis


   
    plotLabelingAlgorithm.setCanvasPanelTitle(canvasPanelTitleTest);
    Assert.assertTrue(plotLabelingAlgorithm.getCanvasPanelTitle().equals(canvasPanelTitleTest));
   
    LegendEntry testEntry = new LegendEntry(Color.white, Color.white, new Font("Arial", Font.PLAIN, 12), new AbbreviatingPlotLabelingAlgorithm());
    testEntry.setPlot(new LinearXYPlotLine(new LinearXYAxis(XYDimension.X), new LinearXYAxis(XYDimension.Y), XYDimension.X));
   
    // Empty string.
    testEntry.setBaseDisplayName("");
    Assert.assertTrue(testEntry.getBaseDisplayNameLabel().equalsIgnoreCase(""));
   
View Full Code Here


  }
 
  public void setXBounds(double minimum, double maximum) {   
    XYAxis axis = getXAxis();
    if (axis == null) {
      axis = new LinearXYAxis(XYDimension.X);
      setXAxis(axis);
      colorize(axis);
    }
    axis.setStart(minimum);
    axis.setEnd(maximum);
View Full Code Here

  }

  public void setYBounds(double minimum, double maximum) {
    XYAxis axis = getYAxis();
    if (axis == null) {
      axis = new LinearXYAxis(XYDimension.Y);
      setYAxis(axis);
      colorize(axis);
    }
    axis.setStart(minimum);
    axis.setEnd(maximum);
View Full Code Here

        xAxis.setEnd(plot.getEndTime().getTimeInMillis());
      } else {
        xAxis.setStart(plot.getEndTime().getTimeInMillis());
        xAxis.setEnd(plot.getStartTime().getTimeInMillis());
      }
      LinearXYAxis yAxis = new LinearXYAxis(XYDimension.Y);
      plot.theNonTimeAxis = yAxis;
      if(plot.getYAxisMaximumLocation() == YAxisMaximumLocationSetting.MAXIMUM_AT_TOP) {
        yAxis.setStart(plot.getPlotAbstraction().getMinNonTime());
        yAxis.setEnd(plot.getPlotAbstraction().getMaxNonTime());
      } else {
        yAxis.setStart(plot.getPlotAbstraction().getMaxNonTime());
        yAxis.setEnd(plot.getPlotAbstraction().getMinNonTime());
      }
      if(plot.isTimeLabelEnabled) {
        xAxis.setPreferredSize(new Dimension(1, 20));
      } else {
        xAxis.setPreferredSize(new Dimension(1, 10));
      }
      yAxis.setPreferredSize(new Dimension(PlotConstants.Y_AXIS_WHEN_NON_TIME_LABEL_WIDTH , 1));
     
      xAxis.setForeground(plot.getTimeAxisColor());
      yAxis.setForeground(plot.getNonTimeAxisColor());
      yAxis.setFormat(getNumberFormatter());
      plot.getPlotView().setXAxis(xAxis);
      plot.getPlotView().setYAxis(yAxis);
      plot.getPlotView().add(xAxis);
      plot.getPlotView().add(yAxis);

      // Setup the axis labels.
      if (plot.isTimeLabelEnabled) {
        SimpleDateFormat format = TimeFormatUtils.makeDataFormat(plot.getTimeFormatSetting());
        xAxis.setFormat(new DateNumberFormat(format));
                xAxis.setTimeSystemAxisLabelName(timeSystemId);
      } else {
        xAxis.setShowLabels(false);
      }

      xAxis.setFont(plot.getTimeAxisFont());
      yAxis.setFont(plot.getTimeAxisFont());

      // Setup the gridlines
      XYGrid grid = new XYGrid(xAxis, yAxis);
      grid.setForeground(plot.getGridLineColor());
      plot.getPlotView().getContents().add(grid);

      xAxis.setMinorTickLength(PlotConstants.MINOR_TICK_MARK_LENGTH);
      xAxis.setMajorTickLength(PlotConstants.MAJOR_TICK_MARK_LENGTH);
      xAxis.setTextMargin(PlotConstants.MAJOR_TICK_MARK_LENGTH + 2);
      yAxis.setMinorTickLength(PlotConstants.MINOR_TICK_MARK_LENGTH);
      yAxis.setMajorTickLength(PlotConstants.MAJOR_TICK_MARK_LENGTH);
      yAxis.setTextMargin(PlotConstants.MAJOR_TICK_MARK_LENGTH + 5);
    } else {
      assert (plot.getAxisOrientationSetting() == AxisOrientationSetting.Y_AXIS_AS_TIME);
      // Setup the axis.
      TimeXYAxis yAxis = new TimeXYAxis(XYDimension.Y);
      if(plot.getYAxisMaximumLocation() == YAxisMaximumLocationSetting.MAXIMUM_AT_TOP) {
        yAxis.setStart(plot.getStartTime().getTimeInMillis());
        yAxis.setEnd(plot.getEndTime().getTimeInMillis());
      } else {
        yAxis.setStart(plot.getEndTime().getTimeInMillis());
        yAxis.setEnd(plot.getStartTime().getTimeInMillis());
      }
      plot.setTimeAxis(yAxis);
      LinearXYAxis xAxis = new LinearXYAxis(XYDimension.X);
      if(plot.getXAxisMaximumLocation() == XAxisMaximumLocationSetting.MAXIMUM_AT_RIGHT) {
        xAxis.setStart(plot.getPlotAbstraction().getMinNonTime());
        xAxis.setEnd(plot.getPlotAbstraction().getMaxNonTime());
      } else {
        xAxis.setStart(plot.getPlotAbstraction().getMaxNonTime());
        xAxis.setEnd(plot.getPlotAbstraction().getMinNonTime());
      }
      plot.theNonTimeAxis = xAxis;

      xAxis.setForeground(plot.getNonTimeAxisColor());
      yAxis.setForeground(plot.getTimeAxisColor());
     
      xAxis.setFormat(getNumberFormatter());
     
      xAxis.setPreferredSize(new Dimension(1, 20));
      yAxis.setPreferredSize(new Dimension(60, 1));
      plot.getPlotView().setXAxis(xAxis);
      plot.getPlotView().setYAxis(yAxis);
      plot.getPlotView().add(xAxis);
      plot.getPlotView().add(yAxis);

      // Setup the axis labels.
      if (plot.isTimeLabelEnabled) {
        SimpleDateFormat format = TimeFormatUtils.makeDataFormat(plot.getTimeFormatSetting());
                yAxis.setFormat(new DateNumberFormat(format));
                yAxis.setTimeSystemAxisLabelName(timeSystemId);
      } else {
        yAxis.setShowLabels(false);
      }

      xAxis.setFont(plot.getTimeAxisFont());
      yAxis.setFont(plot.getTimeAxisFont());

      // Setup the gridlines
      XYGrid grid = new XYGrid(xAxis, yAxis);
      grid.setForeground(plot.getGridLineColor());
      plot.getPlotView().getContents().add(grid);


      xAxis.setMajorTickLength(PlotConstants.MAJOR_TICK_MARK_LENGTH);
      xAxis.setMinorTickLength(PlotConstants.MINOR_TICK_MARK_LENGTH);
      xAxis.setTextMargin(PlotConstants.MAJOR_TICK_MARK_LENGTH + 2);
      yAxis.setMajorTickLength(PlotConstants.MAJOR_TICK_MARK_LENGTH);
      yAxis.setMinorTickLength(PlotConstants.MINOR_TICK_MARK_LENGTH);
      yAxis.setTextMargin(PlotConstants.MAJOR_TICK_MARK_LENGTH + 5);

   
View Full Code Here

    double max = plotPackage.getMaxNonTime();//.getInitialNonTimeMaxSetting();
    xAxis.setFormat(PlotConstants.NON_TIME_FORMAT);
    yAxis.setFormat(PlotConstants.NON_TIME_FORMAT);
       
    for (XYDimension d : XYDimension.values()) {
      LinearXYAxis axis = ((d == XYDimension.X) ? xAxis : yAxis);
      boolean inv = isAxisInverted(d);
      axis.setStart(inv ? max : min);
      axis.setEnd(inv ? min : max);
    }
   
    xAxis.setMinorTickLength(PlotConstants.MINOR_TICK_MARK_LENGTH);
    xAxis.setMajorTickLength(PlotConstants.MAJOR_TICK_MARK_LENGTH);
    xAxis.setTextMargin(PlotConstants.MAJOR_TICK_MARK_LENGTH + 2);
View Full Code Here

    XYPlotFrame frame = new XYPlotFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setup();
    Timer timer = new Timer();

    final LinearXYAxis yAxis = (LinearXYAxis) frame.getYAxis();
    final XYAxis xAxis = frame.getXAxis();
    yAxis.setTickMarkCalculator(new TimeTickMarkCalculator());
    yAxis.setFormat(new DateNumberFormat(new SimpleDateFormat("yyyy-MM-dd\nHH:mm:ss.SSS")));
    yAxis.setPreferredSize(new Dimension(100, 50));
    xAxis.setStartMargin(100);

    final LinearXYPlotLine line = new LinearXYPlotLine(xAxis, yAxis, XYDimension.Y);
    line.setForeground(Color.white);
    final SimpleXYDataset d = new SimpleXYDataset(line);
    d.setMaxCapacity(1000);
    d.setXData(line.getXData());
    d.setYData(line.getYData());
    final XYMarkerLine marker = new XYMarkerLine(xAxis, 60);
    marker.setForeground(Color.yellow);
    XYPlotContents contents = frame.getContents();
    contents.add(marker);
    final XYMarkerLine marker2 = new XYMarkerLine(yAxis, .5);
    marker2.setForeground(Color.red);
    contents.add(marker2);
    frame.addPlotLine(line);

    yAxis.setStart(0);
    yAxis.setEnd(10);
    xAxis.setStart(-1.2);
    xAxis.setEnd(1.2);

    frame.getLocationDisplay().setFormat(new MessageFormat("<html><b>X:</b> {0} &nbsp; <b>Y:</b> {1,date,HH:mm:ss}</html>"));
    frame.getSlopeLineDisplay().setFormat(new MessageFormat("<html><b>&Delta;x:</b> {0}  <b>&Delta;y:</b> {1,date,HH:mm:ss}</html>"));

    timer.schedule(new TimerTask() {
      int x = 0;


      @Override
      public void run() {
        x++;
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            long now = System.currentTimeMillis();
            yAxis.setStart(now / 1000 * 1000 - 9000);
            yAxis.setEnd(now / 1000 * 1000 + 1000);
            double y2 = now;
            double x2 = Math.sin(y2 / 2000.0);
            d.add(x2, y2);
            marker.setValue(x2);
            marker2.setValue(y2);
View Full Code Here

 
  private PlotterPlotContents contents = new PlotterPlotContents();
  private XYGrid              grid;

  public PlotterPlot() {
    setXAxis(new LinearXYAxis(XYDimension.X));
    setYAxis(new LinearXYAxis(XYDimension.Y));
    grid = new XYGrid(getXAxis(), getYAxis());
   
    contents.add(grid);
   
    add(getXAxis());
View Full Code Here

    mockPlot.compressionIsEnabled = true;
    mockPlot.setPlotView(mockPlotView);
    mockPlot.setLimitManager(mockLimitManager);
    Mockito.when(mockPlot.isCompressionEnabled()).thenReturn(true);
    Mockito.when(mockPlotView.getContents()).thenReturn(new XYPlotContents());
    Mockito.when(mockPlotView.getXAxis()).thenReturn(new LinearXYAxis(XYDimension.X));
    Mockito.when(mockPlotView.getYAxis()).thenReturn(new LinearXYAxis(XYDimension.Y));
  }
View Full Code Here

  }
 
  @Test(dataProvider="minMax")
  public void testMinMax(AxisOrientationSetting setting, TimeXYAxis axis) throws Exception {
    plot.setAxisOrientationSetting(setting);
    LinearXYAxis nonTime;
    if (setting == AxisOrientationSetting.X_AXIS_AS_TIME) {
      Mockito.when(plotView.getXAxis()).thenReturn(axis);
      nonTime = new LinearXYAxis(XYDimension.Y);
      Mockito.when(plotView.getYAxis()).thenReturn(nonTime);
    } else {
      Mockito.when(plotView.getYAxis()).thenReturn(axis);
      nonTime = new LinearXYAxis(XYDimension.X);
      Mockito.when(plotView.getXAxis()).thenReturn(nonTime);
    }
    plot.theNonTimeAxis = nonTime;
    Assert.assertNotNull(plot.getPlotView().getXAxis());
    Assert.assertNotNull(plot.getPlotView().getYAxis());
    plot.setTimeAxis(axis);
    plot.setNonTimeMinPadding(0);
    plot.setNonTimeMaxPadding(0);
    axis.setStart(100);
    axis.setEnd(200);
    double initialStart = 0;
    double initialEnd = 10;
    nonTime.setStart(initialStart);
    nonTime.setEnd(initialEnd);
   
    PlotDataManager dataManager = new PlotDataManager(plot);
    setMemberVariable("plotDataManager", dataManager);
    dataManager.addDataSet("TestData", Color.black);
    PlotDataSeries dataSeries = dataManager.getDataSeries().get("TestData");
    CompressingXYDataset dataSet = dataSeries.getData();
    dataSet.setCompressionScale(1);
    addToDataSet(setting, dataSet, 0, 100);
    addToDataSet(setting, dataSet, 5, 101);
    plot.newPointPlotted(100,0);
    plot.newPointPlotted(101,5);
 
    // test the case where the new point is less than the current data maximum, no change should occur
    addToDataSet(setting, dataSet, 4, 101.5);
    plot.newPointPlotted(new Double(101.5).longValue(), 4);
    Assert.assertEquals(nonTime.getStart(),initialStart);
    Assert.assertEquals(nonTime.getEnd(), 5.0);
   
    // test the case where the new point is less than the current axis, no change should occur
    // 2/26/12 Change in axis now occurs because non-Time axis responds to new max 6 in auto-adjust and semi-fixed mode.
    addToDataSet(setting, dataSet, 6, 102);
    plot.newPointPlotted(102, 6);
    Assert.assertEquals(nonTime.getStart(),initialStart);
    Assert.assertEquals(nonTime.getEnd(), 6.0);
   
    // test the case where the new point is greater than the current axis, the axis should increase (or decrease)
    // this should include the padding
    double newMax = 15;
    addToDataSet(setting, dataSet, newMax, 103);
    plot.newPointPlotted(103, newMax);
    Assert.assertEquals(nonTime.getStart(),initialStart);
    Assert.assertEquals(nonTime.getEnd(), newMax);
   
    // test the case where the axis has now been collapsed back to the settings value
    // if a new value comes in that is below the max value but above the current state of the axis, the axis should
    // increase to the maximum value
    nonTime.setEnd(initialEnd);
    double twelve = 12;
    addToDataSet(setting, dataSet, twelve, 104);
    plot.newPointPlotted(104, twelve);
    Assert.assertEquals(nonTime.getStart(),initialStart);
    Assert.assertEquals(nonTime.getEnd(), newMax);
   
    // test where the max value has been truncated off the time line
    // The axis should contract down to 12.0, because newMax has been truncated off
    addToDataSet(setting, dataSet, 10, 105);
    plot.newPointPlotted(105, 10);
    addToDataSet(setting, dataSet, 10, 106);
    plot.newPointPlotted(106, 10);
    addToDataSet(setting, dataSet, 10, 107);
    plot.newPointPlotted(107, 10);
    dataSet.setTruncationOffset(0);
    dataSet.setTruncationPoint(104);
    addToDataSet(setting, dataSet, 10, 108);
    plot.newPointPlotted(108, 10);

    Assert.assertEquals(nonTime.getStart(),initialStart);
    Assert.assertEquals(nonTime.getEnd(), 12.0);
  }
View Full Code Here

TOP

Related Classes of plotter.xy.LinearXYAxis

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.