ch.randelshofer.quaqua.icon.ShiftedIcon Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Quaqua Show documentation
Show all versions of Quaqua Show documentation
A Mavenisation of the Quaqua Mac OSX Swing Look and Feel (Java library)
Quaqua Look and Feel (C) 2003-2010, Werner Randelshofer.
Mavenisation by Matt Gumbley, DevZendo.org - for problems with
Mavenisation, see Matt; for issues with Quaqua, see the Quaqua home page.
For full license details, see http://randelshofer.ch/quaqua/license.html
The newest version!
/*
* @(#)ShiftedIcon.java 1.0 May 12, 2006
*
* Copyright (c) 2006-2010 Werner Randelshofer, Immensee, Switzerland.
* All rights reserved.
*
* You may not use, copy or modify this file, except in compliance with the
* license agreement you entered into with Werner Randelshofer.
* For details see accompanying license terms.
*/
package ch.randelshofer.quaqua.icon;
import java.awt.*;
import javax.swing.*;
/**
* ShiftedIcon renders a target icon at a different location and can return
* different width and height values than the target.
*
* @author Werner Randelshofer.
* @version 1.0 May 12, 2006 Created.
*/
public class ShiftedIcon implements Icon {
private Icon target;
private Rectangle shift;
/** Creates a new instance. */
public ShiftedIcon(Icon target, Point shift) {
this.target = target;
this.shift = new Rectangle(
shift.x, shift.y,
target.getIconWidth(),
target.getIconHeight()
);
}
public ShiftedIcon(Icon target, Rectangle shiftAndSize) {
this.target = target;
this.shift = shiftAndSize;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
target.paintIcon(c, g, x + shift.x, y + shift.y);
}
public int getIconWidth() {
return shift.width;
}
public int getIconHeight() {
return shift.height;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy