/** * */ @Override protected Shape provideShape(Graphics2D g, Object comp, int width, int height) { if(getImage() != null) { BufferedImage bi = getImage(); int imgWidth = bi.getWidth(); int imgHeight = bi.getHeight(); return calculateLayout(imgWidth, imgHeight, width, height); } return new Rectangle(0,0,0,0); }
/** * Sets the scaling factor used when drawing the image * @param imageScale the new image scaling factor */ public void setImageScale(double imageScale) { double old = getImageScale(); this.imageScale = imageScale; setDirty(true); firePropertyChange("imageScale",old,this.imageScale); } /**
public void setScaleType(ScaleType scaleType) { ScaleType old = getScaleType(); this.scaleType = scaleType; setDirty(true); firePropertyChange("scaleType", old, getScaleType()); }
/** * Sets if the image should be repeated horizontally. * @param horizontalRepeat the new horizontal repeat value */ public void setHorizontalRepeat(boolean horizontalRepeat) { boolean old = this.isHorizontalRepeat(); this.horizontalRepeat = horizontalRepeat; setDirty(true); firePropertyChange("horizontalRepeat",old,this.horizontalRepeat); }
/** * Sets if the image should be repeated vertically. * @param verticalRepeat new value for the vertical repeat */ public void setVerticalRepeat(boolean verticalRepeat) { boolean old = this.isVerticalRepeat(); this.verticalRepeat = verticalRepeat; setDirty(true); firePropertyChange("verticalRepeat",old,this.verticalRepeat); }
private void drawBackground(Graphics2D g, Shape shape, int width, int height) { Paint p = getFillPaint(); if(isPaintStretched()) { p = calculateSnappedPaint(p, width, height); if(getAreaEffects() != null) { for(AreaEffect ef : getAreaEffects()) { ef.apply(g, shape, width, height); Insets insets = getInsets(); area.intersect(new Area(new Rectangle(insets.left, insets.top, width - insets.left - insets.right, height - insets.top - insets.bottom))); switch(getHorizontalAlignment()) { case CENTER: x=(width/2)-(sw/2); break; switch(getVerticalAlignment()) { case CENTER: y=(height/2)-(sh/2);
private void drawBackground(Graphics2D g, Shape shape, int width, int height) { Paint p = getFillPaint(); if(isPaintStretched()) { p = calculateSnappedPaint(p, width, height); if(getAreaEffects() != null) { for(AreaEffect ef : getAreaEffects()) { ef.apply(g, shape, width, height); Rectangle rect = calculateLayout(imgWidth, imgHeight, width, height); if(verticalRepeat || horizontalRepeat) { Shape oldClip = g.getClip(); switch(getHorizontalAlignment()) { case CENTER: x=(width/2)-(sw/2); break; switch(getVerticalAlignment()) { case CENTER: y=(height/2)-(sh/2);
assertThat(ip.getImage(), is(nullValue())); assertThat(ip.getImageScale(), is(1d)); assertThat(ip.getScaleType(), is(ImagePainter.ScaleType.InsideFit)); assertThat(ip.isHorizontalRepeat(), is(false)); assertThat(ip.isScaleToFit(), is(false)); assertThat(ip.isVerticalRepeat(), is(false));
/** * {@inheritDoc} */ protected void doPaint(Graphics2D g, Object component, int width, int height) { if (img == null && imageURL != null) { loadImage(); } Shape shape = provideShape(g, component,width,height); switch (getStyle()) { case BOTH: drawBackground(g,shape,width,height); drawBorder(g,shape,width,height); break; case FILLED: drawBackground(g,shape,width,height); break; case OUTLINE: drawBorder(g,shape,width,height); break; case NONE: break; } }
public void setScaleToFit(boolean scaleToFit) { boolean old = isScaleToFit(); this.scaleToFit = scaleToFit; setDirty(true); firePropertyChange("scaleToFit", old, isScaleToFit()); }
public UniformityMeasurementsPanel() { try { assert EventQueue.isDispatchThread(); backgroundImage = ImageIO.read(getClass().getResource(IMAGE_RESOURCE)); painter = new ImagePainter(backgroundImage); painter.setScaleToFit(true); displayPanel.setOpaque(false); displayPanel.setBackgroundPainter(painter); final double imageAspectRatio = (double)backgroundImage.getWidth() / backgroundImage.getHeight(); setLayout(new FixedAspectRatioLayout(imageAspectRatio)); add(displayPanel); displayPanel.add(innerPanel); setOpaque(false); } catch (IOException e) { throw new RuntimeException(e); } }
/** * {@inheritDoc} */ @Override protected ImagePainter createTestingPainter() { return new ImagePainter(); }
private void drawBackground(Graphics2D g, Shape shape, int width, int height) { Paint p = getFillPaint(); if(isPaintStretched()) { p = calculateSnappedPaint(p, width, height); if(getAreaEffects() != null) { for(AreaEffect ef : getAreaEffects()) { ef.apply(g, shape, width, height); Insets insets = getInsets(); area.intersect(new Area(new Rectangle(insets.left, insets.top, width - insets.left - insets.right, height - insets.top - insets.bottom))); switch(getHorizontalAlignment()) { case CENTER: x=(width/2)-(sw/2); break; switch(getVerticalAlignment()) { case CENTER: y=(height/2)-(sh/2);
/** * {@inheritDoc} */ @Override protected void doPaint(Graphics2D g, Object component, int width, int height) { Shape shape = provideShape(g, component,width,height); switch (getStyle()) { case BOTH: drawBackground(g,shape,width,height); drawBorder(g,shape,width,height); break; case FILLED: drawBackground(g,shape,width,height); break; case OUTLINE: drawBorder(g,shape,width,height); break; case NONE: break; default: break; } }
/** * Sets if the image should be repeated horizontally. * @param horizontalRepeat the new horizontal repeat value */ public void setHorizontalRepeat(boolean horizontalRepeat) { boolean old = this.isHorizontalRepeat(); this.horizontalRepeat = horizontalRepeat; setDirty(true); firePropertyChange("horizontalRepeat",old,this.horizontalRepeat); }
/** * Sets if the image should be repeated vertically. * @param verticalRepeat new value for the vertical repeat */ public void setVerticalRepeat(boolean verticalRepeat) { boolean old = this.isVerticalRepeat(); this.verticalRepeat = verticalRepeat; setDirty(true); firePropertyChange("verticalRepeat",old,this.verticalRepeat); }
public void setScaleToFit(boolean scaleToFit) { boolean old = isScaleToFit(); this.scaleToFit = scaleToFit; setDirty(true); firePropertyChange("scaleToFit", old, isScaleToFit()); }
public UniformityMeasurementsPanel() { try { assert EventQueue.isDispatchThread(); backgroundImage = ImageIO.read(getClass().getResource(IMAGE_RESOURCE)); painter = new ImagePainter(backgroundImage); painter.setScaleToFit(true); displayPanel.setOpaque(false); displayPanel.setBackgroundPainter(painter); final double imageAspectRatio = (double)backgroundImage.getWidth() / backgroundImage.getHeight(); setLayout(new FixedAspectRatioLayout(imageAspectRatio)); add(displayPanel); displayPanel.add(innerPanel); setOpaque(false); } catch (IOException e) { throw new RuntimeException(e); } }
public void setImagePainter(TimeSet value, boolean isSelected) { if (value == null) { rendererLabel.setPainter(null); return; } Color background; if (isSelected) { background = SELECTED_BACKGROUND; } else { background = UNSELECTED_BACKGROUND; } TimeIntervalGraphicsParameters params = getTimeIntervalGraphicsParameters(value); final BufferedImage image = timeIntervalGraphics.createTimeIntervalImage( params.starts, params.ends, rendererLabel.getWidth() - 1, rendererLabel.getHeight() - 1, FILL_COLOR, BORDER_COLOR, background ); rendererLabel.setPainter(new ImagePainter(image)); }
private void drawBackground(Graphics2D g, Shape shape, int width, int height) { Paint p = getFillPaint(); if(isPaintStretched()) { p = calculateSnappedPaint(p, width, height); if(getAreaEffects() != null) { for(AreaEffect ef : getAreaEffects()) { ef.apply(g, shape, width, height); Insets insets = getInsets(); area.intersect(new Area(new Rectangle(insets.left, insets.top, width - insets.left - insets.right, height - insets.top - insets.bottom))); switch(getHorizontalAlignment()) { case CENTER: x=(width/2)-(sw/2); break; switch(getVerticalAlignment()) { case CENTER: y=(height/2)-(sh/2);