本文整理汇总了Java中org.jdesktop.swingx.painter.CompoundPainter类的典型用法代码示例。如果您正苦于以下问题:Java CompoundPainter类的具体用法?Java CompoundPainter怎么用?Java CompoundPainter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompoundPainter类属于org.jdesktop.swingx.painter包,在下文中一共展示了CompoundPainter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGlossPainterDemos
import org.jdesktop.swingx.painter.CompoundPainter; //导入依赖的package包/类
private MutableTreeNode createGlossPainterDemos() {
DefaultMutableTreeNode node = createInfoNode("Gloss Painter Demos",
null);
RectanglePainter rp = new RectanglePainter(20, 20, 20,
20, 20, 20);
rp.setFillPaint(Color.RED);
rp.setBorderPaint(Color.RED.darker());
rp.setStyle(RectanglePainter.Style.BOTH);
rp.setBorderWidth(5);
rp.setAntialiasing(true);
CompoundPainter<Object> cp = new CompoundPainter<Object>(rp, new GlossPainter());
node.add(createInfoNode("Gloss on top of rectangle", cp));
rp = new RectanglePainter(20, 20, 20, 20, 20, 20, true,
Color.RED, 5f, Color.RED.darker());
rp.setAntialiasing(true);
cp = new CompoundPainter<Object>(rp, new GlossPainter(GlossPosition.BOTTOM));
node.add(createInfoNode("Gloss on bottom of rectangle", cp));
return node;
}
示例2: rebuildMainMapOverlay
import org.jdesktop.swingx.painter.CompoundPainter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void rebuildMainMapOverlay()
{
CompoundPainter<JXMapViewer> cp = new CompoundPainter<JXMapViewer>();
cp.setCacheable(false);
/*
* List<Painter> ptrs = new ArrayList<Painter>(); if(isDataProviderCreditShown()) {
* ptrs.add(dataProviderCreditPainter); } if(isAddressLocationShown()) { ptrs.add(addressLocationPainter); }
*/
cp.setPainters(dataProviderCreditPainter, addressLocationPainter);
mainMap.setOverlayPainter(cp);
}
示例3: savePainterToImage
import org.jdesktop.swingx.painter.CompoundPainter; //导入依赖的package包/类
public static void savePainterToImage(JComponent testPanel, CompoundPainter compoundPainter, File file) throws IOException {
BufferedImage img = new BufferedImage(testPanel.getWidth(),testPanel.getHeight(),
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = img.createGraphics();
setBGP(testPanel,compoundPainter);
testPanel.paint(g);
ImageIO.write(img,"png",file);
}
示例4: interactiveRestoreDefaultForegroundPainter
import org.jdesktop.swingx.painter.CompoundPainter; //导入依赖的package包/类
/**
* Issue #??-swingx: default foreground painter not guaranteed after change.
*
* JXLabel restore default foreground painter.
* Sequence:
* compose the default with a transparent overlay
* try to reset to default
* try to compose the overlay again.
*/
public void interactiveRestoreDefaultForegroundPainter() {
JComponent box = Box.createVerticalBox();
final JXLabel foreground = new JXLabel(
"setup: compound - default and overlay ");
ShapePainter shapePainter = new ShapePainter();
final AlphaPainter<?> alpha = new AlphaPainter<Object>();
alpha.setAlpha(0.2f);
alpha.setPainters(shapePainter);
CompoundPainter<?> compound = new CompoundPainter<Object>(foreground
.getForegroundPainter(), alpha);
foreground.setForegroundPainter(compound);
box.add(foreground);
Action action = new AbstractActionExt("reset default foreground") {
boolean reset;
public void actionPerformed(ActionEvent e) {
if (reset) {
CompoundPainter<?> painter = new CompoundPainter<Object>(alpha, foreground.getForegroundPainter());
foreground.setForegroundPainter(painter);
} else {
// try to reset to default
foreground.setForegroundPainter(null);
}
reset = !reset;
}
};
JXFrame frame = wrapInFrame(box, "foreground painters");
addAction(frame, action);
frame.pack();
frame.setVisible(true);
}
示例5: initialize
import org.jdesktop.swingx.painter.CompoundPainter; //导入依赖的package包/类
public void initialize(NodeManager nodeManager, Map<String, Car> allCars) {
this.nodeManager = nodeManager;
mapViewer = new JXMapViewer();
TileFactoryInfo info = new OSMTileFactoryInfo();
DefaultTileFactory tileFactory = new DefaultTileFactory(info);
tileFactory.setThreadPoolSize(8);
mapViewer.setTileFactory(tileFactory);
mapViewer.setAddressLocation(new GeoPosition(48.14650327493638,
16.329095363616943));
mapViewer.setZoom(3);
CarPainter carPainter = new CarPainter();
GraphPainter graphPainter = new GraphPainter();
ClusterPainter clusterPainter = new ClusterPainter();
CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>();
painter.addPainter(carPainter);
if (MapsRacer.DEBUG) {
painter.addPainter(graphPainter);
painter.addPainter(clusterPainter);
}
carPainter.initialize(allCars);
graphPainter.initialize(nodeManager.getStreets());
clusterPainter.initialize(nodeManager.getClusters());
mapViewer.setOverlayPainter(painter);
if (MapsRacer.DEBUG) {
MouseInputListener mouseListener = new PanMouseInputListener(
mapViewer);
mapViewer.addMouseListener(mouseListener);
mapViewer.addMouseMotionListener(mouseListener);
}
}
示例6: rebuildMainMapOverlay
import org.jdesktop.swingx.painter.CompoundPainter; //导入依赖的package包/类
private void rebuildMainMapOverlay() {
CompoundPainter cp = new CompoundPainter();
cp.setCacheable(false);
/*
List<Painter> ptrs = new ArrayList<Painter>();
if(isDataProviderCreditShown()) {
ptrs.add(dataProviderCreditPainter);
}
if(isAddressLocationShown()) {
ptrs.add(addressLocationPainter);
}*/
cp.setPainters(dataProviderCreditPainter, addressLocationPainter);
mainMap.setOverlayPainter(cp);
}
示例7: createPinstripePainterDemos
import org.jdesktop.swingx.painter.CompoundPainter; //导入依赖的package包/类
private MutableTreeNode createPinstripePainterDemos() {
DefaultMutableTreeNode node = createInfoNode("Pinstripe Painter Demos", null);
MattePainter black = new MattePainter(Color.BLACK);
PinstripePainter pp = new PinstripePainter(Color.WHITE, 45, 1, 10);
CompoundPainter<Object> cp = new CompoundPainter<Object>(black, pp);
node.add(createInfoNode("45deg white pinstripe on black", cp));
pp = new PinstripePainter(Color.WHITE, 0, 1, 10);
pp.setAntialiasing(true);
cp = new CompoundPainter<Object>(black, pp);
node.add(createInfoNode("vertical white pinstripe on black", cp));
pp = new PinstripePainter(Color.WHITE, 90, 1, 10);
pp.setAntialiasing(true);
cp = new CompoundPainter<Object>(black, pp);
node.add(createInfoNode("horizontal white pinstripe on black", cp));
pp = new PinstripePainter(Color.WHITE, 45, 3, 10);
pp.setAntialiasing(true);
cp = new CompoundPainter<Object>(black, pp);
node.add(createInfoNode("3px wide white pinstripe on black", cp));
pp = new PinstripePainter(Color.WHITE, 45, 10, 2);
pp.setAntialiasing(true);
cp = new CompoundPainter<Object>(black, pp);
node.add(createInfoNode("10px wide pinstripe w/ 2px spacing on black", cp));
pp = new PinstripePainter(Color.WHITE, 45, 3, 15);
pp.setAntialiasing(true);
pp.setPaint(
new GradientPaint(new Point(0, 0), Color.WHITE, new Point(10, 10), Color.BLACK));
cp = new CompoundPainter<Object>(black, pp);
node.add(createInfoNode("pinstripe w/ 10px gradient", cp));
pp = new PinstripePainter(Color.WHITE, 45, 3, 15);
pp.setAntialiasing(true);
pp.setPaint(
new GradientPaint(new Point(0, 0), Color.WHITE, new Point(200, 200), Color.BLACK));
cp = new CompoundPainter<Object>(black, pp);
node.add(createInfoNode("pinstripe w/ 200px gradient", cp));
return node;
}
示例8: IntroPanelDemo
import org.jdesktop.swingx.painter.CompoundPainter; //导入依赖的package包/类
public IntroPanelDemo() {
setName("introPanel");
// <snip> ImagePainters for intro
introImagePainter = new ImagePainter();
introImagePainter.setFillHorizontal(true);
introImagePainter.setVerticalAlignment(VerticalAlignment.TOP);
textImagePainter = new SlidingPainter();
textImagePainter.setVisible(false);
textImagePainter.setHorizontalAlignment(HorizontalAlignment.LEFT);
textImagePainter.setVerticalAlignment(VerticalAlignment.TOP);
setBackgroundPainter(new CompoundPainter<Object>(introImagePainter, textImagePainter));
// </snip>
Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
bind();
}
示例9: main
import org.jdesktop.swingx.painter.CompoundPainter; //导入依赖的package包/类
/**
* @param args the program args (ignored)
*/
public static <T> void main(String[] args)
{
JXMapViewer mapViewer = new JXMapViewer();
// Create a TileFactoryInfo for OpenStreetMap
TileFactoryInfo info = new OSMTileFactoryInfo();
DefaultTileFactory tileFactory = new DefaultTileFactory(info);
tileFactory.setThreadPoolSize(8);
mapViewer.setTileFactory(tileFactory);
GeoPosition frankfurt = new GeoPosition(50, 7, 0, 8, 41, 0);
GeoPosition wiesbaden = new GeoPosition(50, 5, 0, 8, 14, 0);
GeoPosition mainz = new GeoPosition(50, 0, 0, 8, 16, 0);
GeoPosition darmstadt = new GeoPosition(49, 52, 0, 8, 39, 0);
GeoPosition offenbach = new GeoPosition(50, 6, 0, 8, 46, 0);
// Set the focus
mapViewer.setZoom(10);
mapViewer.setAddressLocation(frankfurt);
// Create a track from the geo-positions
List<GeoPosition> track = Arrays.asList(frankfurt, wiesbaden, mainz, darmstadt, offenbach);
RoutePainter routePainter = new RoutePainter(track);
// Create waypoints from the geo-positions
Set<Waypoint> waypoints = new HashSet<Waypoint>(Arrays.asList(
new DefaultWaypoint(frankfurt),
new DefaultWaypoint(wiesbaden),
new DefaultWaypoint(mainz),
new DefaultWaypoint(darmstadt),
new DefaultWaypoint(offenbach)));
// Create a waypoint painter that takes all the waypoints
WaypointPainter<Waypoint> waypointPainter = new WaypointPainter<Waypoint>();
waypointPainter.setWaypoints(waypoints);
// Create a compound painter that uses both the route-painter and the waypoint-painter
List<Painter<JXMapViewer>> painters = new ArrayList<Painter<JXMapViewer>>();
painters.add(routePainter);
painters.add(waypointPainter);
CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>(painters);
mapViewer.setOverlayPainter(painter);
// Display the viewer in a JFrame
JFrame frame = new JFrame("JXMapviewer2 Example 2");
frame.getContentPane().add(mapViewer);
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}