Package jmt.engine.jaba

Examples of jmt.engine.jaba.DPoint


    saturationSects = calc.Calc2D(vertices, stationNames, classNames);
    jres.setSaturationSectors(saturationSects);

    v = new Vector<Point2D>();
    for (int k = 0; k < stationNames.length; k++) {
      v.add(new DPoint(serviceTimes[k][0][0],
          serviceTimes[k][1][0], stationNames[k]));
    }
    convexEngine = new EngineConvex2D(v, saturationSects);
    jres.setConvex(convexEngine.getConvex());
    jres.setAllConvex(convexEngine.getAllConvex());
View Full Code Here


    labels = new ArrayList<String>();
    truePoints = new ArrayList<DPoint>();
    for (i = 0; i < points.size(); i++) {
      labels.add(FORMATTER.format(points.get(i).getX()));
      truePoints.add(new DPoint(getTrueX(points.get(i).getX()),
          getTrueY(points.get(i).getY())));
    }
    placer = new XAxisPlacer(labels, truePoints);
    placer.place(g, getTrueY(0) + SPACE_BETWEEN_X_AXIS_AND_LABEL,
        getTrueY(0));
View Full Code Here

    labels = new ArrayList<String>();
    truePoints = new ArrayList<DPoint>();
    for (i = 0; i < points.size(); i++) {
      labels.add(FORMATTER.format(points.get(i).getY()));
      truePoints.add(new DPoint(getTrueX(points.get(i).getX()),
          getTrueY(points.get(i).getY())));
    }
    placer = new YAxisPlacer(labels, truePoints);
    placer.place(g, SPACE_BETWEEN_LEFT_MARGIN_AND_LABEL);
  }
View Full Code Here

   * @param p
   *            a point
   * @return the coodinates of the @p point into the graphics context
   */
  public DPoint getTruePoint(DPoint p) {
    return new DPoint(getTrueX(p.getX()), getTrueY(p.getY()));
  }
View Full Code Here

   * @param p
   *            a point
   * @return the coodinates of the @p point into the graphics context
   */
  public DPoint getTruePoint(Point2D p) {
    return new DPoint(getTrueX(p.getX()), getTrueY(p.getY()));
  }
View Full Code Here

   * @param p
   *            a point
   * @return the coodinates of the @p point into the plane
   */
  public DPoint getGraphPointFromTruePoint(DPoint p) {
    return new DPoint(xMaxValue * (p.getX() - origin.getX()) / xAxisLenght,
        (origin.getY() - p.getY()) * yMaxValue / yAxisLenght);
  }
View Full Code Here

  public void mouseClicked(MouseEvent ev) {
    if (ev.getButton() == MouseEvent.BUTTON3) {
      super.rightClick(ev);
      return;
    }
    DPoint test = this.adjustMousePoint(ev.getX(), ev.getY());
    for (int i = 0; i < data.getStationNames().length; i++) {
      if (stationLabels[i] != null && stationLabels[i].contains(test)) {
        showStation[i] = !showStation[i];
        repaint();
      }
View Full Code Here

  public void mouseMoved(MouseEvent ev) {
    ArrayList<DPoint>[] util;
    util = data.getResults().getUtilization();

    for (int j = 0; j < data.getStationNames().length; j++) {
      DPoint test = this.adjustMousePoint(ev.getX(), ev.getY());
      if (stationLabels[j] != null && stationLabels[j].contains(test)) {
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        return;
      }
      int i;
      for (i = 0; i < util[j].size(); i = i + 2) {
        if (!showStation[j])
          continue;
        DPoint pointA = plane.getTruePoint(util[j].get(i));
        DPoint pointB = plane.getTruePoint(util[j].get(i + 1));

        Polygon rect = new Polygon();
        rect.addPoint((int) pointA.getX(), (int) pointA.getY() - 16);
        rect.addPoint((int) pointA.getX(), (int) pointA.getY() + 16);
        rect.addPoint((int) pointB.getX(), (int) pointB.getY() - 16);
        rect.addPoint((int) pointB.getX(), (int) pointB.getY() + 16);
        if (rect.contains(test)) {
          tooltip = test;
          repaint();
          return;
        }
View Full Code Here

    Sectors2DPlacer placer;
    Vector<Object> s3d;
    Graphics2D g2;

    DPoint graphOrigin;
    ArrayList<String> labels;
    ArrayList<DPoint> labelPoints, valuesOnY, valuesOnX;

    // If g is not instance of Graphic2D, aborts method
    if (g instanceof Graphics2D) {
      g2 = (Graphics2D) g;
    } else {
      return;
    }
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
        RenderingHints.VALUE_ANTIALIAS_ON);

    try {
      graphOrigin = new DPoint(GRAPH_LEFT_MARGIN,
          (getHeight() - GRAPH_BOTTOM_MARGIN));
      plane = new CartesianPositivePlane(
          g2,
          graphOrigin,
          (int) (getHeight() - GRAPH_TOP_MARGIN - GRAPH_BOTTOM_MARGIN),
          (int) (getHeight() - GRAPH_TOP_MARGIN - GRAPH_BOTTOM_MARGIN),
          1, 1);
    } catch (Exception e) {
      return;
    }
    s3d = data.getResults().getSaturationSectors();
    labels = new ArrayList<String>();
    labelPoints = new ArrayList<DPoint>();
    valuesOnY = new ArrayList<DPoint>();
    valuesOnX = new ArrayList<DPoint>();
    for (int i = 0; i < s3d.size(); i++) {
      String label;
      DPoint sectorBegin, sectorEnd, labelPoint;
      FinalSect2D sect;// Current sector

      sect = (FinalSect2D) s3d.get(i);
      sectorBegin = new DPoint(sect.getBeta1(), sect.getBeta11());
      sectorEnd = new DPoint(sect.getBeta2(), sect.getBeta22());
      // labelPoint is the mean between sectorBegin and sectorEnd
      labelPoint = new DPoint(plane.getTrueX((sectorBegin.getX())
          + ((sectorEnd.getX() - sectorBegin.getX()) / 2)),
          plane.getTrueY((sectorEnd.getY())
              + ((sectorBegin.getY() - sectorEnd.getY()) / 2)));

      valuesOnY.add(sectorBegin);
      valuesOnX.add(sectorBegin);

      switch (sect.getstation().size()) {
      case 1:
        g2.setColor(SINGLE);
        break;
      case 2:
        g2.setColor(DOUBLE);
        break;
      default:
        g2.setColor(MORE);
      }

      g2.setStroke(SECTORS);
      plane.drawSegment(sectorBegin, sectorEnd);
      g2.setStroke(DOTTED);
      g2.setColor(Color.BLACK);
      plane.drawProjectionOnTheXAxis(sectorBegin);
      plane.drawProjectionOnTheXAxis(sectorEnd);
      plane.drawProjectionOnTheYAxis(sectorEnd);
      plane.drawProjectionOnTheYAxis(sectorBegin);
      label = labelGenerator(sect.getstation());
      labels.add(label);
      labelPoints.add(labelPoint);

    }
    g2.setColor(Color.BLACK);
    g2.setStroke(LINES);
    // We draw the plane
    plane.draw(data.getClassNames()[0] + " %", data.getClassNames()[1]
        + " %");
    if (!valuesOnY.contains(new DPoint(0, 1)))
      valuesOnY.add(new DPoint(0, 1));
    if (!valuesOnX.contains(new DPoint(1, 0)))
      valuesOnX.add(new DPoint(1, 0));
    if (!valuesOnX.contains(new DPoint(0, 0)))
      valuesOnX.add(0, new DPoint(0, 0));

    plane.drawValuesOnXAxis(valuesOnX);
    plane.drawValuesOnYAxis(valuesOnY);
    // We draw the labels
    placer = new Sectors2DPlacer(labels, labelPoints);
    placer.place(g2, plane.getTrueX(1) + DISTANCE_BETWEEN_GRAPH_AND_LABELS);

    if (tooltip != null) {
      DPoint graphPoint = plane.getGraphPointFromTruePoint(tooltip);
      String content = FORMATTER.format(graphPoint.getX()) + ", "
          + FORMATTER.format(graphPoint.getY());
      Rectangle2D bounds = g.getFontMetrics().getStringBounds(content, g);
      g.setColor(TOOL_TIP_COLOR);
      g.fillRect((int) tooltip.getX(), (int) tooltip.getY()
          - (int) bounds.getHeight() + 1, (int) bounds.getWidth(),
          (int) bounds.getHeight() + 2);
View Full Code Here

  public void mouseDragged(MouseEvent arg0) {

  }

  public void mouseMoved(MouseEvent ev) {
    DPoint test = adjustMousePoint(ev.getX(), ev.getY());

    DPoint pointA = plane.getTruePoint(new DPoint(0, 1));
    DPoint pointB = plane.getTruePoint(new DPoint(1, 0));

    Polygon rect = new Polygon();
    rect.addPoint((int) pointA.getX(), (int) pointA.getY() - 16);
    rect.addPoint((int) pointA.getX(), (int) pointA.getY() + 16);
    rect.addPoint((int) pointB.getX(), (int) pointB.getY() - 16);
    rect.addPoint((int) pointB.getX(), (int) pointB.getY() + 16);
    if (rect.contains(test)) {
      tooltip = test;
      repaint();
      return;
    }
View Full Code Here

TOP

Related Classes of jmt.engine.jaba.DPoint

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.