コード例 #1
0
 @Override
 protected void setPressed(boolean pressed) {
   super.setPressed(pressed);
   if (pressed) {
     if (!popupadded) {
       Stage stage = getParent().getStage();
       stage.getPopupLayer().add(popup);
     }
     Point2D pt = NodeUtils.convertToScene(this, 0, getHeight());
     popup.setTranslateX(Math.round(Math.max(pt.getX(), 0)));
     popup.setTranslateY(Math.round(Math.max(pt.getY(), 0)));
     popup.setVisible(true);
     EventBus.getSystem().setPressedNode(popup);
   } else {
     // popup.setVisible(false);
   }
 }
コード例 #2
0
  @Override
  public void draw(GFX gfx) {
    float[] curr = toHSB(color);
    float[] start = toHSB(startColor);

    // hue, vertical
    gfx.translate(centerPoint.getX(), centerPoint.getY());
    for (double i = 0; i < 200; i++) {
      FlatColor c = FlatColor.hsb(i / 200 * 360.0, curr[1], curr[2]);
      gfx.setPaint(c);
      double y = start[0] * 200;
      gfx.drawLine(-5, i - y, +5, i - y);
    }
    gfx.translate(-centerPoint.getX(), -centerPoint.getY());

    // saturation, 30 degrees
    gfx.translate(centerPoint.getX(), centerPoint.getY());
    for (double i = 0; i < 200; i++) {
      FlatColor c = FlatColor.hsb(curr[0] * 360, i / 200.0, curr[2]);
      gfx.setPaint(c);
      double sin = Math.sin(Math.toRadians(30));
      double cos = Math.cos(Math.toRadians(30));
      double x = cos * i - cos * start[1] * 200 + 0;
      double y = sin * i - sin * start[1] * 200 + 0;
      // tx = cos(30)*i
      // tx/cos(30) = i
      gfx.drawLine(x, y - 5, x, y + 5);
    }
    gfx.translate(-centerPoint.getX(), -centerPoint.getY());

    // brightness, 150 degrees
    gfx.translate(centerPoint.getX(), centerPoint.getY());
    for (double i = 0; i < 200; i++) {
      FlatColor c = FlatColor.hsb(curr[0] * 360, curr[1], i / 200.0);
      gfx.setPaint(c);
      double sin = Math.sin(Math.toRadians(150));
      double cos = Math.cos(Math.toRadians(150));
      double x = cos * i - cos * start[2] * 200;
      double y = sin * i - sin * start[2] * 200;
      gfx.drawLine(x, y - 5, x, y + 5);
    }
    gfx.translate(-centerPoint.getX(), -centerPoint.getY());

    gfx.setPaint(color);
    double s = 16;
    gfx.fillOval(centerPoint.getX() - s / 2, centerPoint.getY() - s / 2, s, s);
    gfx.setPaint(FlatColor.BLACK);
    gfx.drawOval(centerPoint.getX() - s / 2, centerPoint.getY() - s / 2, s, s);
    gfx.drawRect(0, 0, getWidth(), getHeight());
  }