Recreates the current threshold led images due to the given width
@param SIZE
546319
protected void recreateLedImages(final int SIZE) {
        if (ledImageOff != null) {
            ledImageOff.flush();
        }
        ledImageOff = create_LED_Image(SIZE, 0, model.getLedColor());

        if (ledImageOn != null) {
            ledImageOn.flush();
        }
        ledImageOn = create_LED_Image(SIZE, 1, model.getLedColor());
    }
1150022
public void setCustomViewSizes(Dimension... sizes) {
		assert customSizes != null;
		if (sizes == null) {
			customSizes.clear();
			return;
		}
		customSizes = Arrays.asList(sizes);
	}
137315
public void reshape(int width , int height ) {
		if( padded == null ) {
			binary.reshape(width, height);
		} else {
			binary.reshape(width + 2, height + 2);
			binary.subimage(1, 1, width + 1, height + 1, subimage);
		}
	}
494671
public final void init(final int WIDTH, final int HEIGHT) {
        if (WIDTH <= 1 || HEIGHT <= 1) {
            return;
        }

        if (bgImage != null) {
            bgImage.flush();
        }

        if (lcdImage != null) {
            lcdImage.flush();
        }

        if (glowImageOn != null) {
            glowImageOn.flush();
        }
        glowImageOn = GlowImageFactory.INSTANCE.createLcdGlow(WIDTH, HEIGHT, glowColor, true);

        lcdImage = create_LCD_Image(WIDTH, HEIGHT, null);
        final double CORNER_RADIUS = WIDTH > HEIGHT ? (HEIGHT * 0.095) : (WIDTH * 0.095);
        disabledShape = new RoundRectangle2D.Double(0, 0, WIDTH, HEIGHT, CORNER_RADIUS, CORNER_RADIUS);
        if (isDigitalFont()) {
            lcdValueFont = LCD_DIGITAL_FONT.deriveFont(0.7f * getInnerBounds().height).deriveFont(Font.PLAIN);
            if (useCustomLcdUnitFont) {
                lcdUnitFont = customLcdUnitFont.deriveFont(0.2f * getInnerBounds().height);
            } else {
                lcdUnitFont = LCD_STANDARD_FONT.deriveFont(0.2f * getInnerBounds().height);
            }
        } else {
            lcdValueFont = LCD_STANDARD_FONT.deriveFont(0.625f * getInnerBounds().height);
            if (useCustomLcdUnitFont) {
                lcdUnitFont = customLcdUnitFont.deriveFont(0.2f * getInnerBounds().height);
            } else {
                lcdUnitFont = LCD_STANDARD_FONT.deriveFont(0.2f * getInnerBounds().height);
            }
        }
        lcdInfoFont = LCD_STANDARD_FONT.deriveFont(Font.BOLD, 0.18f * getInnerBounds().height);

        if (lcdThresholdImage != null) {
            lcdThresholdImage.flush();
        }
        lcdThresholdImage = create_LCD_THRESHOLD_Image((int) (HEIGHT * 0.2045454545), (int) (HEIGHT * 0.2045454545), lcdColor.TEXT_COLOR);

        if (!sections.isEmpty()) {
            sectionsBackground.clear();
            sectionsForeground.clear();

            final float[] HSB_START = (Color.RGBtoHSB(lcdColor.GRADIENT_START_COLOR.getRed(), lcdColor.GRADIENT_START_COLOR.getGreen(), lcdColor.GRADIENT_START_COLOR.getBlue(), null));
            final float[] HSB_FRACTION1 = (Color.RGBtoHSB(lcdColor.GRADIENT_FRACTION1_COLOR.getRed(), lcdColor.GRADIENT_FRACTION1_COLOR.getGreen(), lcdColor.GRADIENT_FRACTION1_COLOR.getBlue(), null));
            final float[] HSB_FRACTION2 = (Color.RGBtoHSB(lcdColor.GRADIENT_FRACTION2_COLOR.getRed(), lcdColor.GRADIENT_FRACTION2_COLOR.getGreen(), lcdColor.GRADIENT_FRACTION2_COLOR.getBlue(), null));
            final float[] HSB_FRACTION3 = (Color.RGBtoHSB(lcdColor.GRADIENT_FRACTION3_COLOR.getRed(), lcdColor.GRADIENT_FRACTION3_COLOR.getGreen(), lcdColor.GRADIENT_FRACTION3_COLOR.getBlue(), null));
            final float[] HSB_STOP = (Color.RGBtoHSB(lcdColor.GRADIENT_STOP_COLOR.getRed(), lcdColor.GRADIENT_STOP_COLOR.getGreen(), lcdColor.GRADIENT_STOP_COLOR.getBlue(), null));

            // Hue values of the gradient colors
            final float HUE_START = HSB_START[0];
            final float HUE_FRACTION1 = HSB_FRACTION1[0];
            final float HUE_FRACTION2 = HSB_FRACTION2[0];
            final float HUE_FRACTION3 = HSB_FRACTION3[0];
            final float HUE_STOP = HSB_STOP[0];

            // Brightness values of the gradient colors
            final float BRIGHTNESS_START = HSB_START[2];
            final float BRIGHTNESS_FRACTION1 = HSB_FRACTION1[2];
            final float BRIGHTNESS_FRACTION2 = HSB_FRACTION2[2];
            final float BRIGHTNESS_FRACTION3 = HSB_FRACTION3[2];
            final float BRIGHTNESS_STOP = HSB_STOP[2];

            for (Section section : sections) {
                final Color[] BACKGROUND_COLORS;
                final Color FOREGROUND_COLOR;
                final float[] HSB_SECTION = Color.RGBtoHSB(section.getColor().getRed(), section.getColor().getGreen(), section.getColor().getBlue(), null);
                final float HUE_SECTION = HSB_SECTION[0];
                final float SATURATION_SECTION = HSB_SECTION[1];
                final float BRIGHTNESS_SECTION = HSB_SECTION[2];
                if (!UTIL.isMonochrome(section.getColor())) {
                    // Section color is not monochrome
                    if (lcdColor == LcdColor.SECTIONS_LCD) {
                        BACKGROUND_COLORS = new Color[]{
                            new Color(Color.HSBtoRGB(HUE_SECTION, SATURATION_SECTION, BRIGHTNESS_START - 0.31f)),
                            new Color(Color.HSBtoRGB(HUE_SECTION, SATURATION_SECTION, BRIGHTNESS_FRACTION1 - 0.31f)),
                            new Color(Color.HSBtoRGB(HUE_SECTION, SATURATION_SECTION, BRIGHTNESS_FRACTION2 - 0.31f)),
                            new Color(Color.HSBtoRGB(HUE_SECTION, SATURATION_SECTION, BRIGHTNESS_FRACTION3 - 0.31f)),
                            new Color(Color.HSBtoRGB(HUE_SECTION, SATURATION_SECTION, BRIGHTNESS_STOP - 0.31f))
                        };
                    } else {
                        final float HUE_DIFF = HUE_SECTION - HUE_FRACTION3;
                        BACKGROUND_COLORS = new Color[]{
                            UTIL.setHue(lcdColor.GRADIENT_START_COLOR, (HUE_START + HUE_DIFF) % 360),
                            UTIL.setHue(lcdColor.GRADIENT_FRACTION1_COLOR, (HUE_FRACTION1 + HUE_DIFF) % 360),
                            UTIL.setHue(lcdColor.GRADIENT_FRACTION2_COLOR, (HUE_FRACTION2 + HUE_DIFF) % 360),
                            UTIL.setHue(lcdColor.GRADIENT_FRACTION3_COLOR, (HUE_FRACTION3 + HUE_DIFF) % 360),
                            UTIL.setHue(lcdColor.GRADIENT_STOP_COLOR, (HUE_STOP + HUE_DIFF) % 360)
                        };
                    }
                    FOREGROUND_COLOR = UTIL.setSaturationBrightness(section.getColor(), 0.57f, 0.83f);
                } else {
                    // Section color is monochrome
                    final float BRIGHTNESS_DIFF = BRIGHTNESS_SECTION - BRIGHTNESS_FRACTION1;

                    BACKGROUND_COLORS = new Color[]{
                        UTIL.setSaturationBrightness(lcdColor.GRADIENT_START_COLOR, 0, BRIGHTNESS_START + BRIGHTNESS_DIFF),
                        UTIL.setSaturationBrightness(lcdColor.GRADIENT_FRACTION1_COLOR, 0, BRIGHTNESS_FRACTION1 + BRIGHTNESS_DIFF),
                        UTIL.setSaturationBrightness(lcdColor.GRADIENT_FRACTION2_COLOR, 0, BRIGHTNESS_FRACTION2 + BRIGHTNESS_DIFF),
                        UTIL.setSaturationBrightness(lcdColor.GRADIENT_FRACTION3_COLOR, 0, BRIGHTNESS_FRACTION3 + BRIGHTNESS_DIFF),
                        UTIL.setSaturationBrightness(lcdColor.GRADIENT_STOP_COLOR, 0, BRIGHTNESS_STOP + BRIGHTNESS_DIFF)
                    };
                    if (UTIL.isDark(section.getColor())) {
                        FOREGROUND_COLOR = Color.WHITE;
                    } else {
                        FOREGROUND_COLOR = Color.BLACK;
                    }
                }
                sectionsBackground.add(create_LCD_Image(WIDTH, HEIGHT, BACKGROUND_COLORS));
                sectionsForeground.add(FOREGROUND_COLOR);
            }
        }

        // Quality overlay related parameters
        overlayCornerRadius = WIDTH > HEIGHT ? (HEIGHT * 0.095) - 1 : (WIDTH * 0.095) - 1;
        overlayFactor = (float) (lcdValue / (lcdMaxValue - lcdMinValue));
        if (Double.compare(overlayFactor, 1.0) > 0) {
            factor = 1.0f;
        } else if (Double.compare(overlayFactor, 0) < 0) {
            factor = 0.0f;
        } else {
            factor = overlayFactor;
        }
        overlayColors = new Color[] {
            UTIL.setAlpha(qualityOverlayLookup.getColorAt(factor), 0.5f),
            UTIL.setAlpha(qualityOverlayLookup.getColorAt(factor).darker(), 0.5f),
            UTIL.setAlpha(qualityOverlayLookup.getColorAt(factor), 0.5f)
        };
        final int INSET = (int) (qualityOverlay.getHeight() * 0.0909090909);
        overlayInsets.set(INSET, INSET, INSET, INSET);
        qualityOverlayLookup = new GradientWrapper(new Point2D.Double(overlayInsets.left, 0), new Point2D.Double(lcdImage.getMinX() + lcdImage.getWidth() - overlayInsets.right, 0), qualityOverlayFractions, qualityOverlayColors);
        qualityOverlayGradient = new LinearGradientPaint(new Point2D.Double(0, overlayInsets.top), new Point2D.Double(0, HEIGHT - overlayInsets.bottom), new float[]{0.0f, 0.5f, 1.0f}, overlayColors);
        qualityOverlay.setRoundRect(overlayInsets.left, overlayInsets.top, (INNER_BOUNDS.width * overlayFactor) - overlayInsets.left - overlayInsets.right, INNER_BOUNDS.height - overlayInsets.top - overlayInsets.bottom, overlayCornerRadius, overlayCornerRadius);

        // Prepare bargraph
        bargraphSegmentFactor = 20 / (lcdMaxValue - lcdMinValue);
        prepareBargraph(WIDTH, HEIGHT);
    }
975494
void resize(int size, byte value)
    {
        if (size > _capacity)
        {
            resizeBuf(size);
        }
        while (_size < size)
        {
            _buf[_size++] = value;
        }
    }
784071
function(size) {
        OpenLayers.Renderer.prototype.setSize.apply(this, arguments);
        
        this.rendererRoot.setAttributeNS(null, "width", this.size.w);
        this.rendererRoot.setAttributeNS(null, "height", this.size.h);
    }
1178684
private void configure( int width , int height ) {

		this.imageWidth = width;
		this.imageHeight = height;

		// adjust size based parameters based on image size
		this.minimumContour = minimumContourConfig.computeI(Math.min(width,height));
		this.minimumContour = Math.max(4,minimumContour); // This is needed to avoid processing zero or other impossible
		this.minimumArea = Math.pow(this.minimumContour /4.0,2);
		contourFinder.setMinContour(minimumContour);

		if( helper != null )
			helper.setImageShape(width,height);
	}
926959
private static int sizeToInt(String size) {
		int position = size.indexOf('p');
		if (position < 0) {
			return Integer.parseInt(size);
		}
		return Integer.parseInt(size.substring(0, position));
	}
25149
public void setChannelReceiveBufferSize(int size) {
        this.channelReceiveBufferSize = size;
        if (size < 0 || size > UDPConfigConstants.MAX_UDP_PACKET_SIZE) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "Channel Receive buffer size not within Limits: " + size + " setting to default: " + UDPConfigConstants.MAX_UDP_PACKET_SIZE);
            }
            this.channelReceiveBufferSize = UDPConfigConstants.MAX_UDP_PACKET_SIZE;
        }
    }
1272408
public final void setWidth(final int width) {
        if (style == Style.LIST_COLUMNS && (getDeviceType(context) == DeviceType.TABLET ||
                getOrientation(context) == Orientation.LANDSCAPE)) {
            columnCount = 2;
        } else if (style == Style.GRID) {
            int padding = context.getResources()
                    .getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_horizontal_padding);
            int itemSize = context.getResources()
                    .getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_size);
            columnCount = ((getDeviceType(context) != DeviceType.TABLET &&
                    context.getResources().getConfiguration().orientation ==
                            Configuration.ORIENTATION_PORTRAIT ?
                    context.getResources().getDisplayMetrics().widthPixels : width) - 2 * padding) /
                    itemSize;
        } else {
            columnCount = 1;
        }

        rawItems = null;
        notifyDataSetChanged();
    }
802622
public void onResize(int width, int height) {
		// Center the line in the shell
		int lineWidth = lineElement.getOffsetWidth();
		lineLeftOffset = (width / 2) - (lineWidth / 2);
		DOM.setStyleAttribute(lineElement, "left", lineLeftOffset + "px");

		// Draw the other components
		drawLabels();
		drawTicks();
		drawKnob();
	}
623728
function(size) {
    return function limitResolution(params) {
      if (params.width <= 0 || params.height <= 0) {
        return params;
      }
      var width = params.width;
      var minZoom = pixelRatio() * width / size;
      params.zoom = clamp(params.zoom, minZoom, Infinity);
      return params;
    };
  }
1163317
public static void reshapeDown(ImageBase image, int inputWidth, int inputHeight, int squareWidth) {
		int w = downSampleSize(inputWidth,squareWidth);
		int h = downSampleSize(inputHeight,squareWidth);

		image.reshape(w,h);
	}
1213769
protected BufferedImage create_BARGRAPH_LED_Image(final int WIDTH, final int HEIGHT,
                                                                     final ColorDef COLOR,
                                                                     final Color[] CUSTOM_COLORS) {
        if (WIDTH <= 20 || HEIGHT <= 20) // 20 is needed otherwise the image size could be smaller than 1
        {
            return UTIL.createImage(1, 1, Transparency.TRANSLUCENT);
        }

        final int IMAGE_WIDTH;
        final int IMAGE_HEIGHT;
        if (getOrientation() == Orientation.VERTICAL) {
            // Vertical orientation
            IMAGE_WIDTH = (int) (WIDTH * 0.1214285714);
            IMAGE_HEIGHT = (int) (HEIGHT * 0.0121359223);
        } else {
            // Horizontal orientation
            IMAGE_HEIGHT = (int) (WIDTH * 0.0121359223);
            IMAGE_WIDTH = (int) (HEIGHT * 0.1214285714);
        }

        final BufferedImage IMAGE = UTIL.createImage(IMAGE_WIDTH, IMAGE_HEIGHT, Transparency.TRANSLUCENT);
        final Graphics2D G2 = IMAGE.createGraphics();
        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);


        final Rectangle2D LED = new Rectangle2D.Double(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
        final Point2D CENTER = new Point2D.Double(LED.getCenterX(), LED.getCenterY());
        final float[] FRACTIONS = {
            0.0f,
            1.0f
        };
        final Color[] COLORS;
        if (CUSTOM_COLORS != null && CUSTOM_COLORS.length == 2) {
            COLORS = CUSTOM_COLORS;
        } else {
            COLORS = new Color[]{
                COLOR.LIGHT,
                COLOR.DARK
            };
        }
        final float RADIUS;
        switch (getOrientation()) {
            case VERTICAL:

            default:
                RADIUS = (float) (LED.getWidth() / 2f);
                break;

            case HORIZONTAL:
                RADIUS = (float) (LED.getHeight() / 2f);
                break;
        }
        final RadialGradientPaint GRADIENT = new RadialGradientPaint(CENTER, RADIUS, FRACTIONS, COLORS);
        G2.setPaint(GRADIENT);
        G2.fill(LED);

        G2.dispose();

        return IMAGE;
    }
443462
public void setViewSize(Dimension size) {

		if (size == null) {
			throw new IllegalArgumentException("Resolution cannot be null!");
		}

		if (open.get()) {
			throw new IllegalStateException("Cannot change resolution when webcam is open, please close it first");
		}

		// check if new resolution is the same as current one

		Dimension current = getViewSize();
		if (current != null && current.width == size.width && current.height == size.height) {
			return;
		}

		// check if new resolution is valid

		Dimension[] predefined = getViewSizes();
		Dimension[] custom = getCustomViewSizes();

		assert predefined != null;
		assert custom != null;

		boolean ok = false;
		for (Dimension d : predefined) {
			if (d.width == size.width && d.height == size.height) {
				ok = true;
				break;
			}
		}
		if (!ok) {
			for (Dimension d : custom) {
				if (d.width == size.width && d.height == size.height) {
					ok = true;
					break;
				}
			}
		}

		if (!ok) {
			StringBuilder sb = new StringBuilder("Incorrect dimension [");
			sb.append(size.width).append("x").append(size.height).append("] ");
			sb.append("possible ones are ");
			for (Dimension d : predefined) {
				sb.append("[").append(d.width).append("x").append(d.height).append("] ");
			}
			for (Dimension d : custom) {
				sb.append("[").append(d.width).append("x").append(d.height).append("] ");
			}
			throw new IllegalArgumentException(sb.toString());
		}

		LOG.debug("Setting new resolution {}x{}", size.width, size.height);

		device.setResolution(size);
	}
27173
private BufferedImage create_LCD_Image(final int WIDTH, final int HEIGHT) {
        if (WIDTH <= 0 || HEIGHT <= 0) {
            return null;
        }

        final BufferedImage IMAGE = UTIL.createImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT);
        final Graphics2D G2 = IMAGE.createGraphics();
        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
        G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        final int IMAGE_WIDTH = IMAGE.getWidth();
        final int IMAGE_HEIGHT = IMAGE.getHeight();

        // Background rectangle
        final Point2D BACKGROUND_START = new Point2D.Double(0.0, 0.0);
        final Point2D BACKGROUND_STOP = new Point2D.Double(0.0, IMAGE_HEIGHT);
        if (BACKGROUND_START.equals(BACKGROUND_STOP)) {
            BACKGROUND_STOP.setLocation(0.0, BACKGROUND_START.getY() + 1);
        }

        final float[] BACKGROUND_FRACTIONS = {
            0.0f,
            0.08f,
            0.92f,
            1.0f
        };

        final Color[] BACKGROUND_COLORS = {
            new Color(0.4f, 0.4f, 0.4f, 1.0f),
            new Color(0.5f, 0.5f, 0.5f, 1.0f),
            new Color(0.5f, 0.5f, 0.5f, 1.0f),
            new Color(0.9f, 0.9f, 0.9f, 1.0f)
        };
        Util.INSTANCE.validateGradientPoints(BACKGROUND_START, BACKGROUND_STOP);
        final LinearGradientPaint BACKGROUND_GRADIENT = new LinearGradientPaint(BACKGROUND_START, BACKGROUND_STOP, BACKGROUND_FRACTIONS, BACKGROUND_COLORS);
        //final double BACKGROUND_CORNER_RADIUS = WIDTH * 0.09375;
        final double BACKGROUND_CORNER_RADIUS = WIDTH > HEIGHT ? (HEIGHT * 0.095) : (WIDTH * 0.095);
        final java.awt.geom.RoundRectangle2D BACKGROUND = new java.awt.geom.RoundRectangle2D.Double(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, BACKGROUND_CORNER_RADIUS, BACKGROUND_CORNER_RADIUS);
        G2.setPaint(BACKGROUND_GRADIENT);
        G2.fill(BACKGROUND);

        // Foreground rectangle
        final Point2D FOREGROUND_START = new Point2D.Double(0.0, 1.0);
        final Point2D FOREGROUND_STOP = new Point2D.Double(0.0, IMAGE_HEIGHT - 1);
        if (FOREGROUND_START.equals(FOREGROUND_STOP)) {
            FOREGROUND_STOP.setLocation(0.0, FOREGROUND_START.getY() + 1);
        }

        final float[] FOREGROUND_FRACTIONS = {
            0.0f,
            0.03f,
            0.49f,
            0.5f,
            1.0f
        };

        final Color[] FOREGROUND_COLORS = {
            lcdColor.GRADIENT_START_COLOR,
            lcdColor.GRADIENT_FRACTION1_COLOR,
            lcdColor.GRADIENT_FRACTION2_COLOR,
            lcdColor.GRADIENT_FRACTION3_COLOR,
            lcdColor.GRADIENT_STOP_COLOR
        };

        if (lcdColor == LcdColor.CUSTOM) {
            G2.setPaint(customLcdBackground);
        } else {
            Util.INSTANCE.validateGradientPoints(FOREGROUND_START, FOREGROUND_STOP);
            final LinearGradientPaint FOREGROUND_GRADIENT = new LinearGradientPaint(FOREGROUND_START, FOREGROUND_STOP, FOREGROUND_FRACTIONS, FOREGROUND_COLORS);
            G2.setPaint(FOREGROUND_GRADIENT);
        }
        final double FOREGROUND_CORNER_RADIUS = BACKGROUND.getArcWidth() - 1;
        final java.awt.geom.RoundRectangle2D FOREGROUND = new java.awt.geom.RoundRectangle2D.Double(1, 1, IMAGE_WIDTH - 2, IMAGE_HEIGHT - 2, FOREGROUND_CORNER_RADIUS, FOREGROUND_CORNER_RADIUS);
        G2.fill(FOREGROUND);

        G2.dispose();

        return IMAGE;
    }
1250534
public static BufferedImage resize(BufferedImage image, int width, int height)
    {
        final int transparency = image.getColorModel().getTransparency();
        final BufferedImage resized = createImage(width, height, transparency);
        final Graphics2D g = resized.createGraphics();

        optimizeGraphicsSpeed(g);
        g.drawImage(image, 0, 0, width, height, 0, 0, image.getWidth(), image.getHeight(), null);
        g.dispose();

        return resized;
    }