本文整理汇总了Java中org.jdesktop.swingx.painter.AbstractPainter类的典型用法代码示例。如果您正苦于以下问题:Java AbstractPainter类的具体用法?Java AbstractPainter怎么用?Java AbstractPainter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractPainter类属于org.jdesktop.swingx.painter包,在下文中一共展示了AbstractPainter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initPainterSupport
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
private void initPainterSupport() {
foregroundPainter = new AbstractPainter<JXLabel>() {
protected void doPaint(Graphics2D g, JXLabel label, int width, int height) {
Insets i = getInsets();
g = (Graphics2D) g.create(-i.left, -i.top, width, height);
try {
label.paint(g);
} finally {
g.dispose();
}
}
//if any of the state of the JButton that affects the foreground has changed,
//then I must clear the cache. This is really hard to get right, there are
//bound to be bugs. An alternative is to NEVER cache.
protected boolean shouldUseCache() {
return false;
}
@Override
public boolean equals(Object obj) {
return obj != null && this.getClass().equals(obj.getClass());
}
};
}
示例2: setBackgroundPainter
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Sets a Painter to use to paint the background of this JXPanel.
*
* @param p the new painter
* @see #getBackgroundPainter()
*/
@Override
public void setBackgroundPainter(Painter p) {
Painter old = getBackgroundPainter();
if (old instanceof AbstractPainter) {
((AbstractPainter<?>) old).removePropertyChangeListener(painterChangeListener);
}
backgroundPainter = p;
if (backgroundPainter instanceof AbstractPainter) {
((AbstractPainter<?>) backgroundPainter).addPropertyChangeListener(getPainterChangeListener());
}
firePropertyChange("backgroundPainter", old, getBackgroundPainter());
repaint();
}
示例3: initPainterSupport
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
private void initPainterSupport() {
foregroundPainter = new AbstractPainter<JXLabel>() {
@Override
protected void doPaint(Graphics2D g, JXLabel label, int width, int height) {
Insets i = getInsets();
g = (Graphics2D) g.create(-i.left, -i.top, width, height);
try {
label.paint(g);
} finally {
g.dispose();
}
}
//if any of the state of the JButton that affects the foreground has changed,
//then I must clear the cache. This is really hard to get right, there are
//bound to be bugs. An alternative is to NEVER cache.
@Override
protected boolean shouldUseCache() {
return false;
}
@Override
public boolean equals(Object obj) {
return obj != null && this.getClass().equals(obj.getClass());
}
};
((AbstractPainter<?>) foregroundPainter).setAntialiasing(false);
}
示例4: setLineWrap
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Enables line wrapping support for plain text. By default this support is disabled to mimic default of the JLabel.
* Value of this property has no effect on HTML text.
*
* @param b the new value
*/
public void setLineWrap(boolean b) {
boolean old = isLineWrap();
this.multiLine = b;
if (isLineWrap() != old) {
firePropertyChange("lineWrap", old, isLineWrap());
if (getForegroundPainter() != null) {
// XXX There is a bug here. In order to make painter work with this, caching has to be disabled
((AbstractPainter) getForegroundPainter()).setCacheable(!b);
}
//repaint();
}
}
示例5: interactiveFancyFilter
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Example of how-to apply filters to the label's foreground.
*/
@SuppressWarnings("unchecked")
public void interactiveFancyFilter() {
JXLabel label = new JXLabel("that's the real text");
label.setFont(new Font("SansSerif", Font.BOLD, 80));
AbstractPainter<?> fg = new MattePainter(Color.RED);
fg.setFilters(new BlurFilter());
label.setForegroundPainter(fg);
JXFrame frame = wrapInFrame(label, "fancy filter");
show(frame,400, 400);
}
示例6: testDefaultForegroundNotAntialiasing
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Issue #1164-swingx: do not interfere with core antialiased handling.
*/
@Test
public void testDefaultForegroundNotAntialiasing() {
JXLabel label = new JXLabel();
AbstractPainter<?> painter = (AbstractPainter<?>) label.getForegroundPainter();
assertFalse("foreground painter must not be antialiasing", painter.isAntialiasing());
}
示例7: installPainterListener
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Installs a listener to the painter if appropriate. This implementation
* registers its painterListener if the Painter is of type AbstractPainter.
*/
protected void installPainterListener() {
if (getPainter() instanceof AbstractPainter) {
((AbstractPainter<?>) getPainter())
.addPropertyChangeListener(getPainterListener());
}
}
示例8: uninstallPainterListener
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Uninstalls a listener from the painter if appropriate. This
* implementation removes its painterListener if the Painter is of type
* AbstractPainter.
*/
protected void uninstallPainterListener() {
if (getPainter() instanceof AbstractPainter) {
((AbstractPainter<?>) getPainter())
.removePropertyChangeListener(painterListener);
}
}
示例9: setPainter
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
public void setPainter(Painter<?> painter) {
releaseBaseBindings();
releaseAlignBindings();
releaseAreaBindings();
this.painter = painter;
setBaseEnabled(painter instanceof AbstractPainter<?>);
setAlignEnabled(painter instanceof AbstractLayoutPainter<?>);
setAreaEnabled(painter instanceof AbstractAreaPainter<?>);
}
示例10: installPainterListener
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Installs a listener to the painter if appropriate. This
* implementation registers its painterListener if the Painter is of
* type AbstractPainter.
*/
protected void installPainterListener() {
if (getPainter() instanceof AbstractPainter) {
((AbstractPainter) getPainter())
.addPropertyChangeListener(getPainterListener());
}
}
示例11: uninstallPainterListener
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Uninstalls a listener from the painter if appropriate. This
* implementation removes its painterListener if the Painter is of type
* AbstractPainter.
*/
protected void uninstallPainterListener() {
if (getPainter() instanceof AbstractPainter) {
((AbstractPainter) getPainter())
.removePropertyChangeListener(painterListener);
}
}
示例12: installPainterListener
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Installs a listener to the painter if appropriate. This
* implementation registers its painterListener if the Painter is of
* type AbstractPainter.
*/
protected void installPainterListener() {
if (getPainter() instanceof AbstractPainter) {
((AbstractPainter) getPainter())
.addPropertyChangeListener(getPainterListener());
}
}
示例13: uninstallPainterListener
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Uninstalls a listener from the painter if appropriate. This
* implementation removes its painterListener if the Painter is of type
* AbstractPainter.
*/
protected void uninstallPainterListener() {
if (getPainter() instanceof AbstractPainter) {
((AbstractPainter) getPainter())
.removePropertyChangeListener(painterListener);
}
}
示例14: JXMapViewer
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Create a new JXMapViewer. By default it will use the EmptyTileFactory
*/
public JXMapViewer() {
factory = new EmptyTileFactory();
//setTileFactory(new GoogleTileFactory());
MouseInputListener mia = new PanMouseInputListener();
setRecenterOnClickEnabled(false);
this.addMouseListener(mia);
this.addMouseMotionListener(mia);
this.addMouseWheelListener(new ZoomMouseWheelListener());
this.addKeyListener(new PanKeyListener());
// make a dummy loading image
try {
URL url = this.getClass().getResource("mapviewer/resources/loading.png");
this.setLoadingImage(ImageIO.read(url));
} catch (Throwable ex) {
System.out.println("could not load 'loading.png'");
BufferedImage img = new BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = img.createGraphics();
g2.setColor(Color.black);
g2.fillRect(0,0,16,16);
g2.dispose();
this.setLoadingImage(img);
}
//setAddressLocation(new GeoPosition(37.392137,-121.950431)); // Sun campus
setBackgroundPainter(new AbstractPainter<JXPanel>() {
protected void doPaint(Graphics2D g, JXPanel component, int width, int height) {
doPaintComponent(g);
}
});
}
示例15: JXMapViewer
import org.jdesktop.swingx.painter.AbstractPainter; //导入依赖的package包/类
/**
* Create a new JXMapViewer. By default it will use the EmptyTileFactory
*/
public JXMapViewer() {
factory = new EmptyTileFactory();
//setTileFactory(new GoogleTileFactory());
MouseInputListener mia = new PanMouseInputListener();
setRecenterOnClickEnabled(false);
this.addMouseListener(mia);
this.addMouseMotionListener(mia);
this.addMouseWheelListener(new ZoomMouseWheelListener());
this.addKeyListener(new PanKeyListener());
// make a dummy loading image
try {
URL url = this.getClass().getResource("mapviewer/resources/loading.png");
this.setLoadingImage(ImageIO.read(url));
} catch (Throwable ex) {
System.out.println("could not load 'loading.png'");
BufferedImage img = new BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = img.createGraphics();
g2.setColor(Color.black);
g2.fillRect(0,0,16,16);
g2.dispose();
this.setLoadingImage(img);
}
//setAddressLocation(new GeoPosition(37.392137,-121.950431)); // Sun campus
setBackgroundPainter(new AbstractPainter<JXPanel>() {
protected void doPaint(Graphics2D g, JXPanel component, int width, int height) {
doPaintComponent(g);
}
});
}