Esempio n. 1
0
  /**
   * Construct a Polyline that represents a graph of the Vs function.
   *
   * @param x0 The X-coordinate of the left side of the graph (pixels).
   * @param y0 The Y-coordinate of the top of the graph (pixels).
   * @param width The width of the graph (pixels).
   * @param height The height of the graph (pixels).
   */
  public Polyline getGraph(int x0, int y0, int width, int height) {
    if (!getCltUpToDate()) {
      updateLookupTable();
    }
    // if (graphX == x0 && graphY == y0 &&
    //    graphWidth == width && graphHeight == height)
    // {
    //    return curve;
    // }
    int i;
    int j;
    double ficol5 = cminfo.getFirstColor() - 0.5;
    int ncols = cminfo.getNumColors();
    double fncols = ncols;
    double fh1 = height - 1;
    double fw1 = width - 1;
    int[] tbl = colorLookupTable.getTable();
    int tsize = tbl.length;
    double ftsize = tsize;

    // Need 2 pts on each color.  In worst case, lookup
    // table could change color with every table entry.
    Polyline curve = new Polyline(tsize * 2);
    int[] x = curve.x;
    int[] y = curve.y;

    int col = tbl[0];
    x[0] = x0;
    y[0] = y0 + (int) (fh1 - fh1 * (col - ficol5) / fncols + 0.5);
    for (i = j = 1; i < tsize; i++) {
      if (tbl[i] != col) {
        x[j] = x0 + (int) ((fw1 * i) / ftsize + 0.5);
        y[j] = y[j - 1];
        j++;
        col = tbl[i];
        x[j] = x[j - 1];
        y[j] = y0 + (int) (fh1 - fh1 * (col - ficol5) / fncols + 0.5);
        j++;
      }
    }
    x[j] = x0 + width - 1;
    y[j] = y[j - 1];
    curve.length = j + 1;
    if (cminfo.getNegative()) {
      for (i = 0; i < curve.length; i++) {
        y[i] = height - y[i];
      }
    }
    return curve;
  }
Esempio n. 2
0
  private Polyline bridge(Polyline line1, int x1, int y1, Polyline line2, int x2, int y2) {
    int dy, dx, s;
    Polyline r;

    dy = y2 + line2.dy - y1;
    if (line2.dy == 0) {
      dx = line2.dx;
    } else {
      s = dy * line2.dx;
      dx = s / line2.dy;
    }

    r = new Polyline(dx, dy, line2.link);
    line1.link = new Polyline(x2 + line2.dx - dx - x1, 0, r);

    return r;
  }
  protected Polyline bridge(
      Polyline line1, double x1, double y1, Polyline line2, double x2, double y2) {
    double dx = x2 + line2.dx - x1;
    double dy = 0;
    double s = 0;

    if (line2.dx == 0) {
      dy = line2.dy;
    } else {
      s = dx * line2.dy;
      dy = s / line2.dx;
    }

    Polyline r = createLine(dx, dy, line2.next);
    line1.next = createLine(0, y2 + line2.dy - dy - y1, r);

    return r;
  }
Esempio n. 4
0
    private void update() {
      for (JComponent c : onTerrainOnlyItems) {
        c.setEnabled(currentFollowTerrain);
      }

      for (JComponent c : offTerrainOnlyItems) {
        c.setEnabled(!currentFollowTerrain);
      }

      if (this.currentShape instanceof SurfaceShape) {
        SurfaceShape shape = (SurfaceShape) currentShape;
        ShapeAttributes attr = shape.getAttributes();

        if (attr == null) attr = new BasicShapeAttributes();

        if (!currentBorderStyle.equals("None")) {
          float alpha =
              currentBorderOpacity >= 10
                  ? 1f
                  : currentBorderOpacity <= 0 ? 0f : currentBorderOpacity / 10f;
          Color color = null;
          if (currentBorderColor.equals("Yellow")) color = new Color(1f, 1f, 0f);
          else if (currentBorderColor.equals("Red")) color = new Color(1f, 0f, 0f);
          else if (currentBorderColor.equals("Green")) color = new Color(0f, 1f, 0f);
          else if (currentBorderColor.equals("Blue")) color = new Color(0f, 0f, 1f);

          attr.setDrawOutline(true);
          attr.setOutlineMaterial(new Material(color));
          attr.setOutlineOpacity(alpha);
          attr.setOutlineWidth(currentBorderWidth);
        } else {
          attr.setDrawOutline(false);
        }

        if (!currentInteriorStyle.equals("None")) {
          float alpha =
              currentInteriorOpacity >= 10
                  ? 1f
                  : currentInteriorOpacity <= 0 ? 0f : currentInteriorOpacity / 10f;
          Color color = null;
          if (currentInteriorColor.equals("Yellow")) color = new Color(1f, 1f, 0f);
          else if (currentInteriorColor.equals("Red")) color = new Color(1f, 0f, 0f);
          else if (currentInteriorColor.equals("Green")) color = new Color(0f, 1f, 0f);
          else if (currentInteriorColor.equals("Blue")) color = new Color(0f, 0f, 1f);

          attr.setInteriorMaterial(new Material(color));
          attr.setInteriorOpacity(alpha);
          attr.setDrawInterior(true);
        } else {
          attr.setDrawInterior(false);
        }

        shape.setAttributes(attr);
      } else {
        float alpha =
            currentPathOpacity >= 10 ? 1f : currentPathOpacity <= 0 ? 0f : currentPathOpacity / 10f;
        Color color = null;
        if (currentPathColor.equals("Yellow")) color = new Color(1f, 1f, 0f, alpha);
        else if (currentPathColor.equals("Red")) color = new Color(1f, 0f, 0f, alpha);
        else if (currentPathColor.equals("Green")) color = new Color(0f, 1f, 0f, alpha);
        else if (currentPathColor.equals("Blue")) color = new Color(0f, 0f, 1f, alpha);

        if (currentShape instanceof Polyline) {
          Polyline pl = (Polyline) currentShape;
          pl.setColor(color);
          pl.setLineWidth(currentPathWidth);
          pl.setFollowTerrain(currentFollowTerrain);
          pl.setTerrainConformance(currentTerrainConformance);
          pl.setNumSubsegments(currentNumSubsegments);

          if (currentPathType.equalsIgnoreCase("linear")) pl.setPathType(Polyline.LINEAR);
          else if (currentPathType.equalsIgnoreCase("rhumb line"))
            pl.setPathType(Polyline.RHUMB_LINE);
          else pl.setPathType(Polyline.GREAT_CIRCLE);

          pl.setOffset(currentOffset);

          if (currentPathStyle.equals("Dash")) {
            pl.setStippleFactor(5);
            pl.setStipplePattern((short) 0xAAAA);
          } else {
            pl.setStippleFactor(0); // solid
          }
        }
      }
      this.layer.removeAllRenderables();
      if (this.currentShape != null) this.layer.addRenderable(this.currentShape);
      this.wwjPanel.getWwd().redraw();
    }
 /*    */ public void applyTo(Polyline paramPolyline) /*    */ {
   /* 20 */ super.applyTo(paramPolyline);
   /* 21 */ if (this.__set) paramPolyline.getPoints().addAll(this.points);
   /*    */ }
 public float getWidth() {
   return polyline.getWidth();
 }
 public int getColor() {
   return polyline.getColor();
 }
 /**
  * Sets the color of the polyline.
  *
  * @param color - the color in ARGB format
  */
 public PolylineOptions color(int color) {
   polyline.setColor(color);
   return this;
 }
 public float getAlpha() {
   return polyline.getAlpha();
 }
 public PolylineOptions alpha(float alpha) {
   polyline.setAlpha(alpha);
   return this;
 }
 public PolylineOptions add(LatLng point) {
   polyline.addPoint(point);
   return this;
 }
 public List<LatLng> getPoints() {
   // the getter gives us a copy, which is the safe thing to do...
   return polyline.getPoints();
 }
 /**
  * Sets the width of the polyline.
  *
  * @param width in pixels
  * @return a new PolylineOptions
  */
 public PolylineOptions width(float width) {
   polyline.setWidth(width);
   return this;
 }