/** * Sets the state of the led * @param LED_ON */ public void setLedOn(final boolean LED_ON) { if (ledOn == LED_ON) {return;} ledOn = LED_ON; init(getWidth()); repaint(); }
/** * Sets the type of LED. * @param LED_TYPE Possible values are ROUND, RECT_VERTICAL and RECT_HORIZONTAL */ public void setLedType(final LedType LED_TYPE) { if (ledType == LED_TYPE) {return;} ledType = LED_TYPE; final boolean LED_WAS_ON = currentLedImage.equals(ledImageOn) ? true : false; flushImages(); ledImageOff = create_LED_Image(getWidth(), 0, ledColor, ledType); ledImageOn = create_LED_Image(getWidth(), 1, ledColor, ledType); currentLedImage = LED_WAS_ON == true ? ledImageOn : ledImageOff; repaint(); }
/** * Sets the state of the led * @param LED_ON */ public void setLedOn(final boolean LED_ON) { if (ledOn == LED_ON) {return;} ledOn = LED_ON; init(getWidth()); repaint(); }
/** * Sets the type of LED. * @param LED_TYPE Possible values are ROUND, RECT_VERTICAL and RECT_HORIZONTAL */ public void setLedType(final LedType LED_TYPE) { if (ledType == LED_TYPE) {return;} ledType = LED_TYPE; final boolean LED_WAS_ON = currentLedImage.equals(ledImageOn) ? true : false; flushImages(); ledImageOff = create_LED_Image(getWidth(), 0, ledColor, ledType); ledImageOn = create_LED_Image(getWidth(), 1, ledColor, ledType); currentLedImage = LED_WAS_ON == true ? ledImageOn : ledImageOff; repaint(); }
/** * Returns the current component as buffered image. * To save this buffered image as png you could use for example: * File file = new File("image.png"); * ImageIO.write(Image, "png", file); * @return the current component as buffered image */ public BufferedImage getAsImage() { final BufferedImage IMAGE = UTIL.createImage(getWidth(), getHeight(), Transparency.TRANSLUCENT); final Graphics2D G2 = IMAGE.createGraphics(); paintAll(G2); G2.dispose(); return IMAGE; } // </editor-fold>
/** * Sets the color that will be used to calculate the custom led color * @param COLOR */ public void setCustomLedColor(final Color COLOR) { if (customLedColor.COLOR.equals(COLOR)) {return;} customLedColor = new CustomLedColor(COLOR); final boolean LED_WAS_ON = currentLedImage.equals(ledImageOn) ? true : false; flushImages(); ledImageOff = create_LED_Image(getWidth(), 0, ledColor, ledType); ledImageOn = create_LED_Image(getWidth(), 1, ledColor, ledType); currentLedImage = LED_WAS_ON == true ? ledImageOn : ledImageOff; repaint(); }
/** * Sets the color that will be used to calculate the custom led color * @param COLOR */ public void setCustomLedColor(final Color COLOR) { if (customLedColor.COLOR.equals(COLOR)) {return;} customLedColor = new CustomLedColor(COLOR); final boolean LED_WAS_ON = currentLedImage.equals(ledImageOn) ? true : false; flushImages(); ledImageOff = create_LED_Image(getWidth(), 0, ledColor, ledType); ledImageOn = create_LED_Image(getWidth(), 1, ledColor, ledType); currentLedImage = LED_WAS_ON == true ? ledImageOn : ledImageOff; repaint(); }
/** * Returns the current component as buffered image. * To save this buffered image as png you could use for example: * File file = new File("image.png"); * ImageIO.write(Image, "png", file); * @return the current component as buffered image */ public BufferedImage getAsImage() { final BufferedImage IMAGE = UTIL.createImage(getWidth(), getHeight(), Transparency.TRANSLUCENT); final Graphics2D G2 = IMAGE.createGraphics(); paintAll(G2); G2.dispose(); return IMAGE; } // </editor-fold>
/** * Sets the color of the threshold led. * The LedColor is not a standard color but defines a * color scheme for the led. The default ledcolor is RED * @param LED_COLOR */ public void setLedColor(final LedColor LED_COLOR) { if (ledColor == LED_COLOR) {return;} if (LED_COLOR == null) { ledColor = LedColor.RED_LED; } else { ledColor = LED_COLOR; } final boolean LED_WAS_ON = currentLedImage.equals(ledImageOn) ? true : false; flushImages(); ledImageOff = create_LED_Image(getWidth(), 0, LED_COLOR, ledType); ledImageOn = create_LED_Image(getWidth(), 1, LED_COLOR, ledType); currentLedImage = LED_WAS_ON == true ? ledImageOn : ledImageOff; repaint(); }
/** * Calculates the rectangle that specifies the area that is available * for painting the gauge. This means that if the component has insets * that are larger than 0, these will be taken into account. */ private void calcInnerBounds() { // final java.awt.Insets INSETS = getInsets(); // if (getWidth() - INSETS.left - INSETS.right < getHeight() - INSETS.top - INSETS.bottom) { // INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, getWidth() - INSETS.left - INSETS.right, getHeight() - INSETS.top - INSETS.bottom); // } else { // INNER_BOUNDS.setBounds(INSETS.left + (int) (((double) (getWidth() - INSETS.left - INSETS.right) - (double) (getHeight() - INSETS.top - INSETS.bottom)) / 2.0), INSETS.top, getHeight() - INSETS.top - INSETS.bottom, getHeight() - INSETS.top - INSETS.bottom); // } final Insets INSETS = getInsets(); final int SIZE = (getWidth() - INSETS.left - INSETS.right) <= (getHeight() - INSETS.top - INSETS.bottom) ? (getWidth() - INSETS.left - INSETS.right) : (getHeight() - INSETS.top - INSETS.bottom); //INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, getWidth() - INSETS.left - INSETS.right, getHeight() - INSETS.top - INSETS.bottom); INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, SIZE, SIZE); }
/** * Calculates the rectangle that specifies the area that is available * for painting the gauge. This means that if the component has insets * that are larger than 0, these will be taken into account. */ private void calcInnerBounds() { // final java.awt.Insets INSETS = getInsets(); // if (getWidth() - INSETS.left - INSETS.right < getHeight() - INSETS.top - INSETS.bottom) { // INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, getWidth() - INSETS.left - INSETS.right, getHeight() - INSETS.top - INSETS.bottom); // } else { // INNER_BOUNDS.setBounds(INSETS.left + (int) (((double) (getWidth() - INSETS.left - INSETS.right) - (double) (getHeight() - INSETS.top - INSETS.bottom)) / 2.0), INSETS.top, getHeight() - INSETS.top - INSETS.bottom, getHeight() - INSETS.top - INSETS.bottom); // } final Insets INSETS = getInsets(); final int SIZE = (getWidth() - INSETS.left - INSETS.right) <= (getHeight() - INSETS.top - INSETS.bottom) ? (getWidth() - INSETS.left - INSETS.right) : (getHeight() - INSETS.top - INSETS.bottom); //INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, getWidth() - INSETS.left - INSETS.right, getHeight() - INSETS.top - INSETS.bottom); INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, SIZE, SIZE); }
/** * Sets the color of the threshold led. * The LedColor is not a standard color but defines a * color scheme for the led. The default ledcolor is RED * @param LED_COLOR */ public void setLedColor(final LedColor LED_COLOR) { if (ledColor == LED_COLOR) {return;} if (LED_COLOR == null) { ledColor = LedColor.RED_LED; } else { ledColor = LED_COLOR; } final boolean LED_WAS_ON = currentLedImage.equals(ledImageOn) ? true : false; flushImages(); ledImageOff = create_LED_Image(getWidth(), 0, LED_COLOR, ledType); ledImageOn = create_LED_Image(getWidth(), 1, LED_COLOR, ledType); currentLedImage = LED_WAS_ON == true ? ledImageOn : ledImageOff; repaint(); }
@Override public void componentResized(ComponentEvent event) { final int SIZE = getWidth() <= getHeight() ? getWidth() : getHeight(); java.awt.Container parent = getParent(); if ((parent != null) && (parent.getLayout() == null)) { if (SIZE < getMinimumSize().width || SIZE < getMinimumSize().height) { setSize(getMinimumSize().width, getMinimumSize().height); } else { setSize(SIZE, SIZE); } } else { if (SIZE < getMinimumSize().width || SIZE < getMinimumSize().height) { setPreferredSize(getMinimumSize()); } else { setPreferredSize(new java.awt.Dimension(SIZE, SIZE)); } } calcInnerBounds(); init(INNER_BOUNDS.width); //revalidate(); //repaint(INNER_BOUNDS); } };
@Override public void componentResized(ComponentEvent event) { final int SIZE = getWidth() <= getHeight() ? getWidth() : getHeight(); java.awt.Container parent = getParent(); if ((parent != null) && (parent.getLayout() == null)) { if (SIZE < getMinimumSize().width || SIZE < getMinimumSize().height) { setSize(getMinimumSize().width, getMinimumSize().height); } else { setSize(SIZE, SIZE); } } else { if (SIZE < getMinimumSize().width || SIZE < getMinimumSize().height) { setPreferredSize(getMinimumSize()); } else { setPreferredSize(new java.awt.Dimension(SIZE, SIZE)); } } calcInnerBounds(); init(INNER_BOUNDS.width); //revalidate(); //repaint(INNER_BOUNDS); } };