コード例 #1
0
 public static void main(String[] args) {
   try {
     // The image is loaded either from this
     //   default filename or the first command-
     //   line argument.
     // The second command-line argument specifies
     //   what string will be displayed. The third
     //   specifies at what point in the string the
     //   background color will change.
     String filename = "Raphael.jpg";
     String message = "Java2D";
     int split = 4;
     if (args.length > 0) filename = args[0];
     if (args.length > 1) message = args[1];
     if (args.length > 2) split = Integer.parseInt(args[2]);
     ApplicationFrame f = new ApplicationFrame("ShowOff v1.0");
     f.setLayout(new BorderLayout());
     ShowOff showOff = new ShowOff(filename, message, split);
     f.add(showOff, BorderLayout.CENTER);
     f.setSize(f.getPreferredSize());
     f.center();
     f.setResizable(false);
     f.setVisible(true);
   } catch (Exception e) {
     System.out.println(e);
     System.exit(0);
   }
 }
コード例 #2
0
  public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible()
        && (e.getSource() == optionPane)
        && (JOptionPane.VALUE_PROPERTY.equals(prop)
            || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
      Object value = optionPane.getValue();

      if (value == JOptionPane.UNINITIALIZED_VALUE) return;
      optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

      if (button1.equals(value)) {
        try {
          double a = Double.parseDouble(left.getText());
          double b = Double.parseDouble(right.getText());
          double err = Double.parseDouble(error.getText());

          if (a > b) {
            JOptionPane.showMessageDialog(this, "A < B!!!", null, JOptionPane.ERROR_MESSAGE);
          } else {
            hideIt();
            graphic.startApplyingMethod(parentFrame.getSelectedMethod(), err, a, b);
          }
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this, "Trebuie sa fie numar real!", null, JOptionPane.ERROR_MESSAGE);
        }
      } else if (button2.equals(value)) {
        hideIt();
      }
    }
  }
コード例 #3
0
ファイル: Application.java プロジェクト: flo/tcpbuffer
 public static void main(String... args) {
   String guiString = System.getProperty("gui", Boolean.TRUE.toString());
   boolean gui = Boolean.parseBoolean(guiString);
   if (gui) {
     ApplicationFrame.main(args);
   } else {
     ConsoleApplication.main(args);
   }
 }
コード例 #4
0
ファイル: GUIEnv.java プロジェクト: CSCSI/Triana
  /** @return the TrianaClient for the specified task (null if unknown) */
  public static TrianaClient getTrianaClientFor(Task task) {
    TaskGraph parent;

    if (task instanceof TaskGraph) {
      parent = (TaskGraph) task;
    } else {
      parent = task.getParent();
    }

    TrianaClient client = null;

    while ((parent != null) && (client == null)) {
      client = app.getTrianaClient(parent);

      if (client == null) {
        parent = parent.getParent();
      }
    }

    return client;
  }
コード例 #5
0
  /** Displays the data in a graph. */
  private void showPlot() {
    // Create a data series containing the heading error data...
    XYSeries headingErrorSeries = new XYSeries("Heading Error");
    Enumeration<HeadingDivergenceState> e = divergenceData.elements();
    while (e.hasMoreElements()) {
      HeadingDivergenceState currState = e.nextElement();
      headingErrorSeries.add(
          (currState.time - robotData.getExpStartTime()) / 1000, currState.headingError);
    }

    // Create two data series one containing the times when the robot starts heading
    // towards a waypoint, and another containing the times when the robot arrives at
    // a waypoint
    final XYSeries beginEdgeSeries = new XYSeries("Begin Edge Traveral");
    final XYSeries waypointArrivalSeries = new XYSeries("Waypoint Arrival");
    Vector<PathEdge> pathEdges = robotData.getPathEdges();
    Enumeration<PathEdge> e2 = pathEdges.elements();
    while (e2.hasMoreElements()) {
      PathEdge currEdge = e2.nextElement();
      double beginEdgeTime = (currEdge.getStartTime() - robotData.getExpStartTime()) / 1000.0;
      beginEdgeSeries.add(beginEdgeTime, 0);
      double wayPointArrivalTime = (currEdge.getEndTime() - robotData.getExpStartTime()) / 1000.0;
      waypointArrivalSeries.add(wayPointArrivalTime, 0);
    }

    // Create a dataset out of the data series
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(headingErrorSeries);
    dataset.addSeries(beginEdgeSeries);
    dataset.addSeries(waypointArrivalSeries);

    // Create the chart
    JFreeChart chart =
        ChartFactory.createXYLineChart(
            "Heading Error vs. Time", // chart title
            "Time (s)", // x axis label
            "Heading Error (radians)", // y axis label
            dataset, // the data
            PlotOrientation.VERTICAL, // plot orientation (y axis is vertical)
            true, // include legend
            true, // tooltips
            false // urls
            );

    // Place the legend on top of the chart just below the title.
    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.TOP);

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    //        plot.setBackgroundPaint(Color.lightGray);
    //    //    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    //        plot.setDomainGridlinePaint(Color.white);
    //        plot.setRangeGridlinePaint(Color.white);

    // Display the points and not the lines connecting the points
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true); // display the heading errors as a line
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesLinesVisible(
        1, false); // display the begin edge traversal points as blue dots
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesPaint(1, Color.BLUE);
    renderer.setSeriesShape(1, new java.awt.geom.Ellipse2D.Double(-3, -3, 6, 6));
    renderer.setSeriesLinesVisible(
        2, false); // display the begin edge traversal points as green dots
    renderer.setSeriesShapesVisible(2, true);
    renderer.setSeriesPaint(2, Color.GREEN.darker());
    renderer.setSeriesShape(2, new java.awt.geom.Ellipse2D.Double(-5, -5, 10, 10));
    plot.setRenderer(renderer);

    //        final NumberAxis domainAxis = (NumberAxis)plot.getDomainAxis();
    //        domainAxis.setRange(new Range(0,140));

    //        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    //     // change the auto tick unit selection to integer units only...
    ////        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    //        rangeAxis.setRange(new Range(-Math.PI, Math.PI));

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1000, 600));

    // Create a frame for the chart, then display it.
    ApplicationFrame appFrame = new ApplicationFrame("Heading Error for " + logFileName);
    appFrame.setContentPane(chartPanel);
    appFrame.pack();
    RefineryUtilities.centerFrameOnScreen(appFrame);
    appFrame.setVisible(true);
  }
コード例 #6
0
ファイル: GUIEnv.java プロジェクト: CSCSI/Triana
 public static DesktopView getDesktopViewFor(TaskGraph group) {
   return app.getDesktopViewFor(group);
 }
コード例 #7
0
ファイル: GUIEnv.java プロジェクト: CSCSI/Triana
 /** Remove the specified main triana from the workspace */
 public static void removeTaskGraphContainer(DesktopView cont) {
   app.removeDesktopView(cont);
 }
コード例 #8
0
ファイル: GUIEnv.java プロジェクト: CSCSI/Triana
 public static DesktopView getSelectedDesktopView() {
   return app.getSelectedDesktopView();
 }