예제 #1
0
  /**
   * Is the given sprite visible in the given area.
   *
   * @param sprite The sprite to check.
   * @param X1 The min abscissa of the area.
   * @param Y1 The min ordinate of the area.
   * @param X2 The max abscissa of the area.
   * @param Y2 The max ordinate of the area.
   * @return True if the node lies in the given area.
   */
  protected boolean isSpriteIn(GraphicSprite sprite, double X1, double Y1, double X2, double Y2) {
    if (sprite.isAttachedToNode() && nodeInvisible.contains(sprite.getNodeAttachment().getId())) {
      return false;
    } else if (sprite.isAttachedToEdge() && !isEdgeVisible(sprite.getEdgeAttachment())) {
      return false;
    } else {
      Values size = sprite.getStyle().getSize();
      double w2 = metrics.lengthToPx(size, 0) / 2;
      double h2 = size.size() > 1 ? metrics.lengthToPx(size, 1) / 2 : w2;
      Point2D.Double src = spritePositionPx(sprite); // new Point2D.Double(
      // sprite.getX(),
      // sprite.getY() );

      // Tx.transform( src, src );

      double x1 = src.x - w2;
      double x2 = src.x + w2;
      double y1 = src.y - h2;
      double y2 = src.y + h2;

      if (x2 < X1) return false;
      if (y2 < Y1) return false;
      if (x1 > X2) return false;
      if (y1 > Y2) return false;

      return true;
    }
  }
예제 #2
0
  /**
   * Check if a sprite contains the given point (x,y).
   *
   * @param elt The sprite.
   * @param x The point abscissa.
   * @param y The point ordinate.
   * @return True if (x,y) is in the given element.
   */
  protected boolean spriteContains(GraphicElement elt, double x, double y) {
    Values size = elt.getStyle().getSize();
    double w2 = metrics.lengthToPx(size, 0) / 2;
    double h2 = size.size() > 1 ? metrics.lengthToPx(size, 1) / 2 : w2;
    Point2D.Double dst = spritePositionPx((GraphicSprite) elt); // new
    // Point2D.Double(
    // elt.getX(),
    // elt.getY()
    // );
    // Point2D.Double dst = new Point2D.Double();

    // Tx.transform( src, dst );
    dst.x -= metrics.viewport[0];
    dst.y -= metrics.viewport[1];

    double x1 = dst.x - w2;
    double x2 = dst.x + w2;
    double y1 = dst.y - h2;
    double y2 = dst.y + h2;

    if (x < x1) return false;
    if (y < y1) return false;
    if (x > x2) return false;
    if (y > y2) return false;

    return true;
  }
예제 #3
0
  @Override
  protected void pushDynStyle(
      StyleGroup group, Graphics2D g, Camera camera, GraphicElement element) {
    Color color = group.getFillColor(0);

    if (element != null && group.getFillMode() == FillMode.DYN_PLAIN)
      color = interpolateColor(group, element);

    g.setColor(color);

    if (group.getSizeMode() == SizeMode.DYN_SIZE) {
      Object s = element.getAttribute("ui.size");

      if (s != null) {
        width = metrics.lengthToGu(StyleConstants.convertValue(s));
        height = width;
        w2 = width / 2;
        h2 = height / 2;
      } else {
        size = group.getSize();
        width = metrics.lengthToGu(size, 0);
        height = size.size() > 1 ? metrics.lengthToGu(size, 1) : width;
        w2 = width / 2;
        h2 = height / 2;
      }
    }
  }
예제 #4
0
  /**
   * Is the given node visible in the given area.
   *
   * @param node The node to check.
   * @param X1 The min abscissa of the area.
   * @param Y1 The min ordinate of the area.
   * @param X2 The max abscissa of the area.
   * @param Y2 The max ordinate of the area.
   * @return True if the node lies in the given area.
   */
  protected boolean isNodeIn(GraphicNode node, double X1, double Y1, double X2, double Y2) {
    Values size = node.getStyle().getSize();
    double w2 = metrics.lengthToPx(size, 0) / 2;
    double h2 = size.size() > 1 ? metrics.lengthToPx(size, 1) / 2 : w2;
    Point2D.Double src = new Point2D.Double(node.getX(), node.getY());
    boolean vis = true;

    Tx.transform(src, src);

    double x1 = src.x - w2;
    double x2 = src.x + w2;
    double y1 = src.y - h2;
    double y2 = src.y + h2;

    if (x2 < X1) vis = false;
    else if (y2 < Y1) vis = false;
    else if (x1 > X2) vis = false;
    else if (y1 > Y2) vis = false;

    return vis;
  }
예제 #5
0
  @Override
  protected void pushStyle(StyleGroup group, Graphics2D g, Camera camera) {
    size = group.getSize();
    shape = new Ellipse2D.Double();
    width = metrics.lengthToGu(size, 0);
    height = size.size() > 1 ? metrics.lengthToGu(size, 1) : width;
    w2 = width / 2;
    h2 = height / 2;

    Color color = group.getFillColor(0);

    g.setColor(color);
  }
예제 #6
0
 public final Values values() throws ParseException {
   Values values;
   Value value;
   value = value();
   values = new Values(value.units, value.value);
   label_4:
   while (true) {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case COMA:;
         break;
       default:
         jj_la1[12] = jj_gen;
         break label_4;
     }
     jj_consume_token(COMA);
     value = value();
     values.addValues(value.value);
   }
   {
     if (true) return values;
   }
   throw new Error("Missing return statement in function");
 }
예제 #7
0
  protected double getPaddingYpx() {
    if (padding.units == Style.Units.PX && padding.size() > 1) return padding.get(1);

    return getPaddingXpx();
  }
예제 #8
0
  protected double getPaddingXpx() {
    if (padding.units == Style.Units.PX && padding.size() > 0) return padding.get(0);

    return 0;
  }
예제 #9
0
 /**
  * Set the graph padding.
  *
  * @param graph The graphic graph.
  */
 public void setPadding(GraphicGraph graph) {
   padding.copy(graph.getStyle().getPadding());
 }