Package jaron.gui

Examples of jaron.gui.Rect


   * <code>draw</code> method of the Processing Development Environment. This
   * ensures that the slider is updated periodically.
   */
  public void draw() {
    // get the panel's rectangles for easy access
    Rect frame = panel.getFrame();
    Rect content = panel.getContent();
   
    // initialize the graphics environment
    applet.fill(Colors.GRAY_BACKGROUND);
    applet.stroke(Colors.STROKE);
    applet.strokeWeight(1);

    // draw the bounds frame
    applet.rect(frame.getLeft(), frame.getTop(), frame.getWidth(), frame.getHeight());
    // draw the content frame
    applet.rect(content.getLeft(), content.getTop(), content.getWidth(), content.getHeight());
    // draw the label's frame
    applet.rect(panel.labelBottom.getLeft(), panel.labelBottom.getTop(), panel.labelBottom.getWidth(), panel.labelBottom.getHeight());
    applet.rect(panel.labelRight.getLeft(), panel.labelRight.getTop(), panel.labelRight.getWidth(), panel.labelRight.getHeight());
   
    // draw the slider
View Full Code Here


   * <code>draw</code> method of the Processing Development Environment. This
   * ensures that the joystick is updated periodically.
   */
  public void draw() {
    // get the panel's rectangles for easy access
    Rect frame = panel.getFrame();
    Rect content = panel.getContent();
   
    // initialize the graphics environment
    applet.fill(Colors.GRAY_BACKGROUND);
    applet.stroke(Colors.STROKE);
    applet.strokeWeight(1);

    // draw the bounds frame
    applet.rect(frame.getLeft(), frame.getTop(), frame.getWidth(), frame.getHeight());
    // draw the content frame
    applet.rect(content.getLeft(), content.getTop(), content.getWidth(), content.getHeight());
    // draw the label's frame
    applet.rect(panel.labelBottom.getLeft(), panel.labelBottom.getTop(), panel.labelBottom.getWidth(), panel.labelBottom.getHeight());
    applet.rect(panel.labelRight.getLeft(), panel.labelRight.getTop(), panel.labelRight.getWidth(), panel.labelRight.getHeight());
    // draw a closing line
    applet.line(frame.getLeft() + content.getWidth(), frame.getTop(), frame.getLeft() + content.getWidth(), frame.getTop() + frame.getHeight());
   
    // draw the control (stick)
    if (isMousePressed()) applet.fill(Colors.CONTROL_CLICKED);
    else if (isMouseOver()) applet.fill(Colors.CONTROL_MOUSE_OVER);
    else  applet.fill(Colors.CONTROL);
    double midX = getSignalX().getLow() + (getSignalX().getBandwidth() / 2);
    double valueX = (getSignalX().getValue() - midX);
    double maxSignalX = (getSignalX().getBandwidth()/2);
    double degX =  Math.toRadians(35 * valueX / maxSignalX);
    double x = Math.cos(degX) * control.getWidth();
    double offsetX = control.getWidth() - x;
    float centerX = content.getLeft() + (content.getWidth() / 2);
    if (degX < 0) offsetX = 0;
    double midY = getSignalY().getLow() + (getSignalY().getBandwidth() / 2);
    double valueY = (getSignalY().getValue() - midY);
    double maxSignalY = (getSignalY().getBandwidth()/2);
    double degY =  Math.toRadians(35 * valueY / maxSignalY);
    double y = Math.cos(degY) * control.getHeight();
    double offsetY = control.getHeight() - y;
    float centerY = content.getTop() + (content.getHeight() / 2);
    if (degY < 0) offsetY = 0;

    if (centerY > control.getTop() + (float )(offsetY + y)) {
      // bottom right
      applet.line(centerX, centerY, control.getLeft() + (float )(offsetX + x), control.getTop() + (float )(offsetY + y));
      // bottom left
      applet.line(centerX, centerY, control.getLeft() + (float )offsetX, control.getTop() + (float )(offsetY + y));
    }
    if (centerY < control.getTop()) {
      // top right
      applet.line(centerX, centerY, control.getLeft() + (float )offsetX, control.getTop() + (float )offsetY);
      // top left
      applet.line(centerX, centerY, control.getLeft() + (float )(offsetX + x), control.getTop() + (float )offsetY);
    }
    if (centerX > control.getLeft() + (float )(offsetX + x)) {
      // bottom right
      applet.line(centerX, centerY, control.getLeft() + (float )(offsetX + x), control.getTop() + (float )(offsetY + y));
      // top left
      applet.line(centerX, centerY, control.getLeft() + (float )(offsetX + x), control.getTop() + (float )offsetY);
    }
    if (centerX < control.getLeft()) {
      // bottom left
      applet.line(centerX, centerY, control.getLeft() + (float )offsetX, control.getTop() + (float )(offsetY + y));
      // top right
      applet.line(centerX, centerY, control.getLeft() + (float )offsetX, control.getTop() + (float )offsetY);
    }
    applet.rect(control.getLeft() + (float )offsetX, control.getTop() + (float )offsetY, (float )x, (float )y);

    // draw the bottom label (x-axis)
    applet.pushMatrix();
    applet.translate(panel.labelBottom.getLeft(), panel.labelBottom.getTop());
    // draw the label's text
    applet.fill(Colors.TEXT);
    applet.textFont(Fonts.getFontBold(applet), Fonts.FONT_SIZE);
    applet.textAlign(PApplet.LEFT);
    applet.text(labelX, Fonts.LINE_SPACING, Fonts.LINE_HEIGHT);
    // draw the label's value
    applet.textFont(Fonts.getFontPlain(applet), Fonts.FONT_SIZE);
    applet.textAlign(PApplet.RIGHT);
    applet.text(String.format("%1.2f", getValueX()), content.getWidth() - Fonts.LINE_SPACING, Fonts.LINE_HEIGHT);
    applet.popMatrix();

    // draw the right label (y-axis)
    applet.pushMatrix();
    applet.translate(panel.labelRight.getLeft(), panel.labelRight.getTop() + panel.labelRight.getHeight());
View Full Code Here

   * @param width     the component's width
   */
  public Label(PApplet applet, String text, int left, int top, int width, int height) {
    this.applet = applet;
    this.text = text;
    frame = new Rect(left, top, width, height);
  }
View Full Code Here

TOP

Related Classes of jaron.gui.Rect

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.