Package plotter.xy

Examples of plotter.xy.XYPlot


    final Axis[] yAxes = new Axis[numPlots];
    final SimpleXYDataset[][] datasets = new SimpleXYDataset[numPlots][linesPerPlot];
    SlopeLine slopeLine = new SlopeLine();
    slopeLine.setForeground(Color.white);
    for(int i = 0; i < numPlots; i++) {
      final XYPlot plot = new XYPlot();
      final XYAxis xAxis = new LinearXYAxis(XYDimension.X);
      final XYAxis yAxis = new LinearXYAxis(XYDimension.Y);
      xAxis.setPreferredSize(new Dimension(1, 30));
      yAxis.setPreferredSize(new Dimension(40, 1));
      xAxis.setForeground(Color.white);
      yAxis.setForeground(Color.white);
      xAxis.setTextMargin(10);
      yAxis.setTextMargin(10);
      plot.add(xAxis);
      plot.add(yAxis);
      plot.setXAxis(xAxis);
      plot.setYAxis(yAxis);
      plot.setBackground(Color.darkGray);
      XYGrid grid = new XYGrid(xAxis, yAxis);
      grid.setForeground(Color.lightGray);
      XYPlotContents contents = new XYPlotContents();
      contents.setBackground(Color.black);
      plot.add(contents);
      contents.add(grid);
      plot.setPreferredSize(new Dimension(150, 100));

      new DefaultXYLayoutGenerator().generateLayout(plot);

      for(int j = 0; j < linesPerPlot; j++) {
        final LinearXYPlotLine line = new LinearXYPlotLine(xAxis, yAxis, XYDimension.X);
View Full Code Here


    frame.setVisible(true);
  }


  private static SimpleXYDataset createPlot(Container contentPane, boolean invertX, boolean invertY) {
    final XYPlot plot = new XYPlot();
    XYAxis xAxis = new LinearXYAxis(XYDimension.X);
    XYAxis yAxis = new LinearXYAxis(XYDimension.Y);
    xAxis.setPreferredSize(new Dimension(1, 40));
    yAxis.setPreferredSize(new Dimension(40, 1));
    xAxis.setForeground(Color.white);
    yAxis.setForeground(Color.white);
    xAxis.setTextMargin(10);
    yAxis.setTextMargin(10);
    plot.add(xAxis);
    plot.add(yAxis);
    plot.setXAxis(xAxis);
    plot.setYAxis(yAxis);
    plot.setBackground(Color.darkGray);
    XYPlotContents contents = new XYPlotContents();
    contents.setBackground(Color.black);
    plot.setBackground(Color.darkGray);
    XYGrid grid = new XYGrid(xAxis, yAxis);
    grid.setForeground(Color.lightGray);
    contents.add(grid);
    plot.add(contents);
    plot.setPreferredSize(new Dimension(150, 100));
   
    contentPane.setBackground(Color.darkGray);
   
    XYLocationDisplay locationDisplay = new XYLocationDisplay();
    // This is a hack to set the preferred height to the normal height so the component doesn't collapse to height 0 when the text is empty.
    // Note that mimimumSize does not work for some reason.
    locationDisplay.setText("Ag");
    Dimension size = locationDisplay.getPreferredSize();
    size.width = 100;
    locationDisplay.setText("");
    locationDisplay.setPreferredSize(size);
    // End hack
    locationDisplay.setForeground(Color.white);
    locationDisplay.setFont(new Font("Arial", 0, 12));
    locationDisplay.setFormat(new MessageFormat("<html><b>X:</b> {0} &nbsp; <b>Y:</b> {1}</html>"));
    locationDisplay.attach(plot);
    plot.add(locationDisplay);

    SlopeLine slopeLine = new SlopeLine();
    slopeLine.setForeground(Color.white);
    slopeLine.attach(plot);
   
    SlopeLineDisplay slopeLineDisplay = new SlopeLineDisplay();
    slopeLine.addListenerForPlot(plot, slopeLineDisplay);
    slopeLineDisplay.setFont(new Font("Arial", 0, 12));
    slopeLineDisplay.setForeground(Color.white);
    slopeLineDisplay.setFormat(new MessageFormat("<html><b>&Delta;x:</b> {0}  <b>&Delta;y:</b> {1}</html>"));
    plot.add(slopeLineDisplay);

    new DefaultXYLayoutGenerator().generateLayout(plot);

    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS));
    contentPane.add(plot);
View Full Code Here


  public void setup() {
    Container contentPane = getContentPane();

    plot = new XYPlot();
    xAxis = createXAxis();
    yAxis = createYAxis();
    xAxis.setPreferredSize(new Dimension(1, 40));
    yAxis.setPreferredSize(new Dimension(40, 1));
    xAxis.setForeground(Color.white);
View Full Code Here

    System.out.println("Compression ratio: " + 100.0 * (size - size2) / (double) size);
  }


  private static SimpleXYDataset createPlot(Container contentPane) {
    final XYPlot plot = new XYPlot();
    XYAxis xAxis = new LinearXYAxis(XYDimension.X);
    XYAxis yAxis = new LinearXYAxis(XYDimension.Y);
    xAxis.setPreferredSize(new Dimension(1, 40));
    yAxis.setPreferredSize(new Dimension(40, 1));
    xAxis.setForeground(Color.white);
    yAxis.setForeground(Color.white);
    xAxis.setTextMargin(10);
    yAxis.setTextMargin(10);
    plot.add(xAxis);
    plot.add(yAxis);
    plot.setXAxis(xAxis);
    plot.setYAxis(yAxis);
    plot.setBackground(Color.darkGray);
    XYPlotContents contents = new XYPlotContents();
    contents.setBackground(Color.black);
    plot.setBackground(Color.darkGray);
    XYGrid grid = new XYGrid(xAxis, yAxis);
    grid.setForeground(Color.lightGray);
    contents.add(grid);
    plot.add(contents);
    plot.setPreferredSize(new Dimension(150, 100));
   
    contentPane.setBackground(Color.darkGray);
   
    XYLocationDisplay locationDisplay = new XYLocationDisplay();
    // This is a hack to set the preferred height to the normal height so the component doesn't collapse to height 0 when the text is empty.
    // Note that mimimumSize does not work for some reason.
    locationDisplay.setText("Ag");
    Dimension size = locationDisplay.getPreferredSize();
    size.width = 100;
    locationDisplay.setText("");
    locationDisplay.setPreferredSize(size);
    // End hack
    locationDisplay.setForeground(Color.white);
    locationDisplay.setFont(new Font("Arial", 0, 12));
    locationDisplay.setFormat(new MessageFormat("<html><b>X:</b> {0} &nbsp; <b>Y:</b> {1}</html>"));
    locationDisplay.attach(plot);
    plot.add(locationDisplay);

    SlopeLine slopeLine = new SlopeLine();
    slopeLine.setForeground(Color.white);
    slopeLine.attach(plot);

    SlopeLineDisplay slopeLineDisplay = new SlopeLineDisplay();
    slopeLine.addListenerForPlot(plot, slopeLineDisplay);
    slopeLineDisplay.setFont(new Font("Arial", 0, 12));
    slopeLineDisplay.setForeground(Color.white);
    slopeLineDisplay.setFormat(new MessageFormat("<html><b>&Delta;x:</b> {0}  <b>&Delta;y:</b> {1}</html>"));
    plot.add(slopeLineDisplay);

    contentPane.add(plot);
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS));

    new DefaultXYLayoutGenerator().generateLayout(plot);
View Full Code Here

                PlotConstants.ARROW_BUTTON_BORDER_STYLE_LEFT,
                PlotConstants.ARROW_BUTTON_BORDER_STYLE_BOTTOM,
                PlotConstants.ARROW_BUTTON_BORDER_STYLE_RIGHT));
    nonTimeMaxLimitButton.setFocusPainted(false);
    nonTimeMaxLimitButton.setToolTipText(BUNDLE.getString("ShowAllData"));
    XYPlot plotView = plot.getPlotView();
    plotView.add(nonTimeMaxLimitButton);
    plotView.setComponentZOrder(nonTimeMaxLimitButton, 0);
    XYPlotContents contents = plotView.getContents();
    SpringLayout layout = (SpringLayout) plotView.getLayout();
    if (plot.getAxisOrientationSetting() == AxisOrientationSetting.X_AXIS_AS_TIME) {
      if (plot.getYAxisMaximumLocation() == YAxisMaximumLocationSetting.MAXIMUM_AT_TOP) {
        layout.putConstraint(SpringLayout.NORTH, nonTimeMaxLimitButton, 0, SpringLayout.NORTH, contents);
        layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, nonTimeMaxLimitButton, 0, SpringLayout.HORIZONTAL_CENTER, contents);
      } else if (plot.getYAxisMaximumLocation() == YAxisMaximumLocationSetting.MAXIMUM_AT_BOTTOM) {
        layout.putConstraint(SpringLayout.SOUTH, nonTimeMaxLimitButton, 0, SpringLayout.SOUTH, contents);
        layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, nonTimeMaxLimitButton, 0, SpringLayout.HORIZONTAL_CENTER, contents);
      }
    } else if (plot.getAxisOrientationSetting() == AxisOrientationSetting.Y_AXIS_AS_TIME){
      if (plot.getXAxisMaximumLocation() == XAxisMaximumLocationSetting.MAXIMUM_AT_LEFT) {
        layout.putConstraint(SpringLayout.WEST, nonTimeMaxLimitButton, 0, SpringLayout.WEST, contents);
        layout.putConstraint(SpringLayout.VERTICAL_CENTER, nonTimeMaxLimitButton, 0, SpringLayout.VERTICAL_CENTER, contents);
      } else if (plot.getXAxisMaximumLocation() == XAxisMaximumLocationSetting.MAXIMUM_AT_RIGHT){
        layout.putConstraint(SpringLayout.EAST, nonTimeMaxLimitButton, 0, SpringLayout.EAST, contents);
        layout.putConstraint(SpringLayout.VERTICAL_CENTER, nonTimeMaxLimitButton, 0, SpringLayout.VERTICAL_CENTER, contents);
      }
    }

    nonTimeMinLimitButton = new JButton(nonTimeMinLimitAlarmRaisedIcon );
    nonTimeMinLimitButton.setVisible(false);
    nonTimeMinLimitButton.setContentAreaFilled( false );
    nonTimeMinLimitButton.setBorder(BorderFactory.createEmptyBorder(PlotConstants.ARROW_BUTTON_BORDER_STYLE_TOP,
                                             PlotConstants.ARROW_BUTTON_BORDER_STYLE_LEFT,
                                             PlotConstants.ARROW_BUTTON_BORDER_STYLE_BOTTOM,
                                             PlotConstants.ARROW_BUTTON_BORDER_STYLE_RIGHT));
    nonTimeMinLimitButton.setFocusPainted(false);
    nonTimeMinLimitButton.setToolTipText(BUNDLE.getString("ShowAllData"));
    nonTimeMaxLimitButton.addActionListener(this);
    nonTimeMinLimitButton.addActionListener(this);   
    plotView.add(nonTimeMinLimitButton);
    plotView.setComponentZOrder(nonTimeMinLimitButton, 0);
    if (plot.getAxisOrientationSetting() == AxisOrientationSetting.X_AXIS_AS_TIME) {
      if (plot.getYAxisMaximumLocation() == YAxisMaximumLocationSetting.MAXIMUM_AT_TOP) {
        layout.putConstraint(SpringLayout.SOUTH, nonTimeMinLimitButton, 0, SpringLayout.SOUTH, contents);
        layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, nonTimeMinLimitButton, 0, SpringLayout.HORIZONTAL_CENTER, contents);
      } else if (plot.getYAxisMaximumLocation() == YAxisMaximumLocationSetting.MAXIMUM_AT_BOTTOM) {
View Full Code Here

  void createPlotInstance() {
    assert plot.getPlotView()==null: "Plot already initalized.";

    // Create new instance of the plot
    plot.setPlotView(new XYPlot());
    plot.getPlotView().setBackground(PlotConstants.DEFAULT_PLOT_FRAME_BACKGROUND_COLOR);
    XYPlotContents contents = new XYPlotContents();
    contents.setBackground(Color.black);
    plot.getPlotView().add(contents);
    plot.getPlotView().setPreferredSize(new Dimension(PlotterPlot.PLOT_PREFERED_WIDTH, PlotterPlot.PLOT_PREFERED_HEIGHT));
View Full Code Here

    Dimension size = pointerXYValueLabel.getPreferredSize();
    size.width = 100;
    pointerXYValueLabel.setText("");
    pointerXYValueLabel.setPreferredSize(size);

    XYPlot plot = parentPlot.getPlotView();
    XYPlotContents contents = plot.getContents();
    plot.add(pointerXYValueLabel);
    plot.add(timeSystemFormattedLabel);
   
    SpringLayout layout2 = (SpringLayout) plot.getLayout();
        layout2.putConstraint(SpringLayout.NORTH, pointerXYValueLabel, 0, SpringLayout.NORTH, plot);
        layout2.putConstraint(SpringLayout.WEST, pointerXYValueLabel, 0, SpringLayout.WEST, contents);
        layout2.putConstraint(SpringLayout.WEST, timeSystemFormattedLabel, 0, SpringLayout.WEST, contents);
        layout2.putConstraint(SpringLayout.NORTH, timeSystemFormattedLabel, 0, SpringLayout.NORTH, plot);
        layout2.putConstraint(SpringLayout.WEST, pointerXYValueLabel, 10, SpringLayout.EAST, timeSystemFormattedLabel);
       
        // Pick the tallest label to lay out the plot contents against
        JComponent top = (pointerXYValueLabel.getPreferredSize().height > timeSystemFormattedLabel.getPreferredSize().height) ?
            pointerXYValueLabel : timeSystemFormattedLabel;
        layout2.putConstraint(SpringLayout.NORTH, contents, 0, SpringLayout.SOUTH, top);       
        plot.getYAxis().setEndMargin(top.getPreferredSize().height);
  }
View Full Code Here

    Dimension size = slopeLabel.getPreferredSize();
    size.width = 100;
    slopeLabel.setText("");
    slopeLabel.setPreferredSize(size);

    XYPlot plot = parentPlot.getPlotView();
    plot.add(slopeLabel);
    XYPlotContents contents = plot.getContents();
    SpringLayout layout2 = (SpringLayout) plot.getLayout();
    layout2.putConstraint(SpringLayout.NORTH, slopeLabel, 0, SpringLayout.NORTH, plot);
        layout2.putConstraint(SpringLayout.EAST, slopeLabel, 0, SpringLayout.EAST, contents);
        layout2.putConstraint(SpringLayout.WEST, timeSystemFormattedLabel, 0, SpringLayout.WEST, contents);
        layout2.putConstraint(SpringLayout.NORTH, timeSystemFormattedLabel, 0, SpringLayout.NORTH, plot);
        layout2.putConstraint(SpringLayout.WEST, pointerXYValueLabel, 10, SpringLayout.EAST, timeSystemFormattedLabel);

        // Pick the tallest label to lay out the plot contents against
        JComponent top = (pointerXYValueLabel.getPreferredSize().height > timeSystemFormattedLabel.getPreferredSize().height) ?
            pointerXYValueLabel : timeSystemFormattedLabel;
        layout2.putConstraint(SpringLayout.NORTH, contents, 0, SpringLayout.SOUTH, top);       
        plot.getYAxis().setEndMargin(top.getPreferredSize().height);       
  }
View Full Code Here

      return legendWidth;
    }
  }
 
  private void realign (XYPlotComponents xyPlotComps, int yAxisWidth, int legendWidth, int fullWidth, int fullHeight) {
    XYPlot plot  = xyPlotComps.getPlot();
    XYAxis yAxis = xyPlotComps.getYAxis();
    LegendManager legend = xyPlotComps.getLegend();
       
    yAxis.setPreferredSize(new Dimension ( yAxisWidth,
      yAxis.getPreferredSize().height));     
   
    /* X Axis starts at left edge of Y Axis, so margin must equal Y Axis width */
    xyPlotComps.getXAxis().setStartMargin(yAxisWidth);
     
    legend.setPreferredSize(new Dimension(legendWidth,
        legend.getPreferredSize().height));
     
    plot.setPreferredSize(new Dimension(fullWidth, fullHeight))
   
    /* Initially, let the slope & location displays be as big as they want */
    JLabel  slopeDisplay    = xyPlotComps.getSlopeLineDisplay();
    JLabel  locationDisplay = xyPlotComps.getLocationDisplay();
    letSizeFreely(slopeDisplay);
    letSizeFreely(locationDisplay);

    /* Then clamp them to content width */
    int contentWidth = plot.getContents().getWidth();
    if (slopeDisplay.getPreferredSize().width    > contentWidth) {
      slopeDisplay.setPreferredSize(new Dimension (contentWidth, slopeDisplay.getPreferredSize().height));
    }
    if (locationDisplay.getPreferredSize().width > contentWidth) {
      locationDisplay.setPreferredSize(new Dimension (contentWidth, locationDisplay.getPreferredSize().height));
    }
   
    /* Hide the location display if there is insufficient room */
    if (!slopeDisplay.getText().isEmpty() && locationDisplay.getPreferredSize().width + slopeDisplay.getPreferredSize().width > contentWidth) {
      locationDisplay.setPreferredSize(new Dimension (1,locationDisplay.getPreferredSize().height));
    }
   
    /* Finally, request that these new preferred sizes get enforced */
    plot.revalidate();   
  }
 
View Full Code Here

//    Assert.assertTrue(testQC.isNonTimeAxisInverted());   
//  }

  @Test
  public void testScientificNotation() {
    XYPlot xyPlot = new XYPlot();
    Mockito.when(mockPlot.getPlotView()).thenReturn(null, xyPlot);
    Mockito.when(mockPlot.getStartTime()).thenReturn(new GregorianCalendar());
    Mockito.when(mockPlot.getEndTime()).thenReturn(new GregorianCalendar());
    Mockito.when(mockPlot.getAxisOrientationSetting()).thenReturn(AxisOrientationSetting.X_AXIS_AS_TIME);
    Mockito.when(mockPlot.getPlotAbstraction()).thenReturn(mockPlotAbstraction);
View Full Code Here

TOP

Related Classes of plotter.xy.XYPlot

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.