本文整理匯總了Java中javax.swing.RepaintManager類的典型用法代碼示例。如果您正苦於以下問題:Java RepaintManager類的具體用法?Java RepaintManager怎麽用?Java RepaintManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RepaintManager類屬於javax.swing包,在下文中一共展示了RepaintManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testPropertySheetRepaintsCellOnPropertyChange
import javax.swing.RepaintManager; //導入依賴的package包/類
public void testPropertySheetRepaintsCellOnPropertyChange() throws Exception {
if (!canSafelyRunFocusTests()) {
return;
}
Node n = new TNode(new SingleTagEditor());
setCurrentNode(n, ps);
Rectangle test = ps.table.getCellRect(1, 1, true);
RM rm = new RM(test, ps.table);
RepaintManager.setCurrentManager(rm);
sleep();
sleep();
Node.Property prop = n.getPropertySets()[0].getProperties()[0];
prop.setValue("new value");
Thread.currentThread().sleep(1000);
sleep();
rm.assertRectRepainted();
}
示例2: doShowBusyCursor
import javax.swing.RepaintManager; //導入依賴的package包/類
private static void doShowBusyCursor(boolean busy) {
JFrame mainWindow = (JFrame)WindowManager.getDefault().getMainWindow();
if(busy){
RepaintManager.currentManager(mainWindow).paintDirtyRegions();
mainWindow.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
mainWindow.getGlassPane().setVisible(true);
mainWindow.repaint();
} else {
mainWindow.getGlassPane().setVisible(false);
mainWindow.getGlassPane().setCursor(null);
mainWindow.repaint();
}
}
示例3: initBufferingAndFonts
import javax.swing.RepaintManager; //導入依賴的package包/類
/**
* Method description
*
* @see
*/
final public void initBufferingAndFonts() {
// Hardware double-buffering :
RepaintManager.currentManager(this).setDoubleBufferingEnabled(false);
this.setIgnoreRepaint(true);
// Waiting for the frame to be displayed :
while (!this.isVisible()) {
Thread.yield();
}
// Images :
final Graphics2D objLjuggleMasterProJFrameGraphics2D = (Graphics2D) this.getGraphics();
this.initBounds();
// Font metrics :
this.objGnormalFont = objLjuggleMasterProJFrameGraphics2D.getFont();
this.objGboldFont = this.objGnormalFont.deriveFont(Font.BOLD);
Constants.objS_GRAPHICS_FONT_METRICS = objLjuggleMasterProJFrameGraphics2D.getFontMetrics();
objLjuggleMasterProJFrameGraphics2D.dispose();
}
示例4: print
import javax.swing.RepaintManager; //導入依賴的package包/類
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
if (pageIndex >= getComponentCount()) {
mLastPage = -1;
return NO_SUCH_PAGE;
}
// We do the following trick to avoid going through the work twice,
// as we are called twice for each page, the first of which doesn't
// seem to be used.
if (mLastPage != pageIndex) {
mLastPage = pageIndex;
} else {
Component comp = getComponent(pageIndex);
RepaintManager mgr = RepaintManager.currentManager(comp);
boolean saved = mgr.isDoubleBufferingEnabled();
mgr.setDoubleBufferingEnabled(false);
mOkToPaint = true;
comp.print(graphics);
mOkToPaint = false;
mgr.setDoubleBufferingEnabled(saved);
}
return PAGE_EXISTS;
}
示例5: init
import javax.swing.RepaintManager; //導入依賴的package包/類
public static void init( Window applicationWindow ) {
if ( inited ) {
throw new RuntimeException( "Multiple inits." );
}
// System.out.println( "Setting repaintManagerPhet." );
RepaintManager.setCurrentManager( repaintManagerPhet );
offscreen = new JWindow( applicationWindow ) {
public void invalidate() {
}
public void paint( Graphics g ) {
}
}; //this seems to work. I thought you might have needed a visible component, though (maybe for some JVM implementations?)
// System.out.println( "offscreen.getOwner() = " + offscreen.getOwner() );
// offscreen.getOwner().setVisible( true );
offscreen.setSize( 0, 0 );
offscreen.setVisible( true );
offscreenContentPane.setOpaque( false );
offscreen.setContentPane( offscreenContentPane );
inited = true;
}
示例6: paint
import javax.swing.RepaintManager; //導入依賴的package包/類
/**
* Renders the wrapped component to the graphics context provided.
*
* @param g2 graphics context for rendering the JComponent
*/
public void paint(final Graphics2D g2) {
if (component.getBounds().isEmpty()) {
// The component has not been initialized yet.
return;
}
final PSwingRepaintManager manager = (PSwingRepaintManager) RepaintManager.currentManager(component);
manager.lockRepaint(component);
final RenderingHints oldHints = g2.getRenderingHints();
//Disable Fractional Metrics on Mac OS because when FRACTIONAL_METRICS are enabled on Mac OS, spurious ellipses
// are rendered on PSwing text components. Disabling the FRACTIONAL_METRICS rendering hint on Windows causes
// incorrect rendering of adjacent text PSwing nodes.
if (System.getProperty("os.name").startsWith( "Mac OS X" )) {
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
}
component.paint(g2);
g2.setRenderingHints(oldHints);
manager.unlockRepaint(component);
}
示例7: testUnlockRepaint
import javax.swing.RepaintManager; //導入依賴的package包/類
public void testUnlockRepaint() {
final PSwingCanvas canvas = new PSwingCanvas();
final RepaintManager currentManager = RepaintManager.currentManager(canvas);
assertNotNull(currentManager);
assertTrue(currentManager instanceof PSwingRepaintManager);
final PSwingRepaintManager repaintManager = (PSwingRepaintManager) currentManager;
repaintManager.lockRepaint(null);
repaintManager.lockRepaint(canvas);
repaintManager.unlockRepaint(null);
repaintManager.unlockRepaint(canvas);
// TODO: catch this array index out of bounds exception?
final JComponent notLocked = new JPanel();
try {
repaintManager.unlockRepaint(notLocked);
}
catch (final ArrayIndexOutOfBoundsException e) {
// expected
}
}
示例8: testAddInvalidComponent
import javax.swing.RepaintManager; //導入依賴的package包/類
public void testAddInvalidComponent() {
final PSwingCanvas canvas = new PSwingCanvas();
final RepaintManager currentManager = RepaintManager.currentManager(canvas);
assertNotNull(currentManager);
assertTrue(currentManager instanceof PSwingRepaintManager);
final PSwingRepaintManager repaintManager = (PSwingRepaintManager) currentManager;
// TODO: should check for null and throw IAE, or keep NPE?
try {
repaintManager.addInvalidComponent(null);
}
catch (final NullPointerException e) {
// expected
}
final JComponent component = new JPanel();
final JComponent child = new JPanel();
canvas.add(child);
repaintManager.addInvalidComponent(canvas);
repaintManager.addInvalidComponent(component);
repaintManager.addInvalidComponent(child);
// TODO: will need some additional work here for full test coverage
}
示例9: print
import javax.swing.RepaintManager; //導入依賴的package包/類
public int print(Graphics g, PageFormat pageFormat, int pageIndex)
throws PrinterException {
if (pageIndex > 0) {
return NO_SUCH_PAGE;
} else {
Graphics2D g2d = (Graphics2D) g;
g2d.setBackground(Color.white);
g2d.translate(pageFormat.getImageableX(), pageFormat
.getImageableY());
Dimension td = this.getPreferredSize();
double sx = pageFormat.getImageableWidth() / td.width;
double sy = pageFormat.getImageableHeight() / td.height;
double s = Math.min(sx, sy);
if (s < 1.)
g2d.scale(s, s);
RepaintManager.currentManager(this)
.setDoubleBufferingEnabled(false);
this.respondToDocumentChange = true;
this.paint(g2d);
RepaintManager.currentManager(this).setDoubleBufferingEnabled(true);
return PAGE_EXISTS;
}
}
示例10: paint
import javax.swing.RepaintManager; //導入依賴的package包/類
/**
* Renders the wrapped component to the graphics context provided.
*
* @param g2 graphics context for rendering the JComponent
*/
public void paint(final Graphics2D g2) {
if (component.getBounds().isEmpty()) {
// The component has not been initialized yet.
return;
}
final PSwingRepaintManager manager = (PSwingRepaintManager) RepaintManager.currentManager(component);
manager.lockRepaint(component);
final RenderingHints oldHints = g2.getRenderingHints();
if (useBufferedPainting) {
Graphics2D bufferedGraphics = getBufferedGraphics(g2);
component.paint(bufferedGraphics);
g2.drawRenderedImage(buffer, IDENTITY_TRANSFORM);
} else {
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
component.paint(g2);
}
g2.setRenderingHints(oldHints);
manager.unlockRepaint(component);
}
示例11: print
import javax.swing.RepaintManager; //導入依賴的package包/類
@Override
public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
if (pageIndex > 0) {
return NO_SUCH_PAGE;
}
else {
Graphics2D g2d = (Graphics2D) g;
RepaintManager currentManager = RepaintManager.currentManager(this);
currentManager.setDoubleBufferingEnabled(false);
Rectangle bounds = getContentBounds(Config.getInstance().getPrintPadding(), getGridElements());
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
AffineTransform t = g2d.getTransform();
double scale = Math.min(pageFormat.getImageableWidth() / bounds.width,
pageFormat.getImageableHeight() / bounds.height);
if (scale < 1) {
t.scale(scale, scale);
g2d.setTransform(t);
}
g2d.translate(-bounds.x, -bounds.y);
paint(g2d);
currentManager = RepaintManager.currentManager(this);
currentManager.setDoubleBufferingEnabled(true);
return PAGE_EXISTS;
}
}
示例12: installUI
import javax.swing.RepaintManager; //導入依賴的package包/類
public void installUI(JComponent c)
{
if (c instanceof JTerminal)
{
this.terminal = (JTerminal)c;
if (graphicsDebugMode)
{
javax.swing.RepaintManager repaintManager = javax.swing.RepaintManager.currentManager(terminal);
repaintManager.setDoubleBufferingEnabled(false);
terminal.setDebugGraphicsOptions(javax.swing.DebugGraphics.FLASH_OPTION);
}
this.session = terminal.getSession();
// session.setRunningHeadless(true);
installComponents();
installListeners();
installDefaults();
installKeyboardActions();
}
else
throw new Error("TerminalUI needs JTerminal");
}
示例13: paintImmediately
import javax.swing.RepaintManager; //導入依賴的package包/類
/**
* Immediately repaints the surface.
*
* <p/>It's possible to turn off double-buffering for just the repaint calls invoked directly on the non double
* buffered component. This can be done by overriding paintImmediately() (which is called as a result of repaint)
* and getting the current RepaintManager and turning off double buffering in the RepaintManager before calling
* super.paintImmediately(g).
*
* @param x The X coord to start painting at.
* @param y The Y coord to start painting at.
* @param w The width of the region to paint.
* @param h The height of the region to paint.
*/
public void paintImmediately(int x, int y, int w, int h)
{
RepaintManager repaintManager = null;
boolean save = true;
if (!isDoubleBuffered())
{
repaintManager = RepaintManager.currentManager(this);
save = repaintManager.isDoubleBufferingEnabled();
repaintManager.setDoubleBufferingEnabled(false);
}
super.paintImmediately(x, y, w, h);
if (repaintManager != null)
{
repaintManager.setDoubleBufferingEnabled(save);
}
}
示例14: getComponentImage
import javax.swing.RepaintManager; //導入依賴的package包/類
@Override
public BufferedImage getComponentImage(Object compObj) {
BufferedImage image = null;
if (compObj instanceof Component) {
Component component = (Component) compObj;
if (component == null || component.getWidth() <= 0 || component.getHeight() <= 0)
return null;
else {
image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);
// switch off double buffering
RepaintManager.currentManager(component).setDoubleBufferingEnabled(false);
component.paint(image.getGraphics());
// switch on double buffering
RepaintManager.currentManager(component).setDoubleBufferingEnabled(true);
}
}
return image;
}
示例15: paintWidget
import javax.swing.RepaintManager; //導入依賴的package包/類
/**
* Paints the component widget.
*/
@Override
protected final void paintWidget() {
RepaintManager rm = RepaintManager.currentManager(null);
boolean isDoubleBuffered = component instanceof JComponent && rm.isDoubleBufferingEnabled();
if (isDoubleBuffered) {
rm.setDoubleBufferingEnabled(false);
}
Graphics2D graphics = getGraphics();
Rectangle bounds = getClientArea();
AffineTransform previousTransform = graphics.getTransform();
graphics.translate(bounds.x, bounds.y);
//double zoomFactor = getScene().getZoomFactor();
//graphics.scale(1 / zoomFactor, 1 / zoomFactor);
if (componentVisible) {
componentWrapper.doPaint(graphics);
} else {
component.paint(graphics);
}
graphics.setTransform(previousTransform);
if (isDoubleBuffered) {
rm.setDoubleBufferingEnabled(true);
}
}