当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.translate方法代码示例

本文整理汇总了Java中java.awt.Graphics.translate方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.translate方法的具体用法?Java Graphics.translate怎么用?Java Graphics.translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics的用法示例。


在下文中一共展示了Graphics.translate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintRaisedBevel

import java.awt.Graphics; //导入方法依赖的package包/类
protected void paintRaisedBevel(Component c, Graphics g, int x, int y, int width, int height) {
    if (!c.isEnabled()) {
        return;
    }

    Color oldColor = g.getColor();
    int h = height;
    int w = width;

    g.translate(x, y);

    g.setColor(getHighlightInnerColor(c));
    g.drawLine(0, 0, 0, h - 1);
    g.drawLine(1, 0, w - 1, 0);

    g.setColor(getShadowOuterColor(c));
    g.drawLine(0, h - 1, w - 1, h - 1);
    g.drawLine(w - 1, 0, w - 1, h - 2);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:JTitledPanel.java

示例2: paintComponent

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintComponent (Graphics g) {
    Dimension d_check = check == null ? new Dimension(0, 0) : check.getSize();
    Dimension d_label = stringDisplayer == null ? new Dimension(0,0) : 
        stringDisplayer.getPreferredSize();

    int y_check = 0;
    int y_label = 0;

    if (d_check.height >= d_label.height) {
        y_label = (d_check.height - d_label.height) / 2;
    }
    if (check != null) {
        check.setBounds (0, 0, d_check.width, d_check.height);
        check.paint(g);
    }
    if (stringDisplayer != null) {
        int y = y_label-2;
        stringDisplayer.setBounds (d_check.width, y, 
            d_label.width, getHeight()-1);
        g.translate (d_check.width, y_label);
        stringDisplayer.paint(g);
        g.translate (-d_check.width, -y_label);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:DeletedListRenderer.java

示例3: drawGroove

import java.awt.Graphics; //导入方法依赖的package包/类
public static void drawGroove(Graphics g, int x, int y, int w, int h,
                              Color shadow, Color highlight)
{
    Color oldColor = g.getColor();  // Make no net change to g
    g.translate(x, y);

    g.setColor(shadow);
    g.drawRect(0, 0, w-2, h-2);

    g.setColor(highlight);
    g.drawLine(1, h-3, 1, 1);
    g.drawLine(1, 1, w-3, 1);

    g.drawLine(0, h-1, w-1, h-1);
    g.drawLine(w-1, h-1, w-1, 0);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:MotifGraphicsUtils.java

示例4: paintThumb

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
    if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) {
        return;
    }

    int w = thumbBounds.width;
    int h = thumbBounds.height;

    g.translate(thumbBounds.x, thumbBounds.y);
    g.setColor(thumbColor);
    g.fillRect(0, 0, w - 1, h - 1);

    g.setColor(thumbHighlightColor);
    drawVLine(g, 0, 0, h - 1);
    drawHLine(g, 1, w - 1, 0);

    g.setColor(thumbLightShadowColor);
    drawHLine(g, 1, w - 1, h - 1);
    drawVLine(g, w - 1, 1, h - 2);

    g.translate(-thumbBounds.x, -thumbBounds.y);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:MotifScrollBarUI.java

示例5: paint

import java.awt.Graphics; //导入方法依赖的package包/类
public synchronized void paint(Graphics g) {
    Tab selectedtab = null;
    Tab workingtab;

    int cwxloc = getMaxLength();//current working x location.. for
                                // graphics context transpose.
    int selectedcwxloc = 0;//yippy.

    for (int i = tabs.size() - 1; i >= 0; i--) {
        workingtab = getTab(i);
        cwxloc -= workingtab.getSize().width;
        g.translate(cwxloc, 0);
        workingtab.paint(g);
        g.translate(-cwxloc, 0);
        if (workingtab.isSelected()) {
            selectedtab = workingtab;
            selectedcwxloc = cwxloc;
        }
        cwxloc += overlap;
    }

    g.translate(selectedcwxloc, 0);
    if (selectedtab != null)
        selectedtab.paint(g);
    g.translate(-selectedcwxloc, 0);
}
 
开发者ID:addertheblack,项目名称:myster,代码行数:27,代码来源:TabPanel.java

示例6: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@Override public void paint(Graphics gr) {
    gr.setColor(Color.GREEN);
    ((Graphics2D)gr).setStroke(new BasicStroke(3));

    gr.translate(width/2, height/2);
    int R = width/4;
    gr.drawOval(-R, -R, 2*R, 2*R);
    gr.drawLine(-R, R, R, -R);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:MyCursor.java

示例7: paintInstance

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
	Location loc = painter.getLocation();
	int x = loc.getX();
	int y = loc.getY();
	Graphics g = painter.getGraphics();
	g.translate(x, y);
	g.setColor(Color.BLACK);
	paintGhost(painter);
	g.translate(-x, -y);
	painter.drawPorts();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:13,代码来源:Tunnel.java

示例8: runTest

import java.awt.Graphics; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
    RenderTests.Context rctx = (RenderTests.Context) ctx;
    int size = rctx.size - 1;
    int x = rctx.initX;
    int y = rctx.initY;
    Graphics g = rctx.graphics;
    g.translate(rctx.orgX, rctx.orgY);
    Color rCArray[] = rctx.colorlist;
    int ci = rctx.colorindex;
    if (rctx.animate) {
        do {
            if (rCArray != null) {
                g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
            }
            g.drawLine(x, y, x + size, y);
            if ((x -= 3) < 0) x += rctx.maxX;
            if ((y -= 1) < 0) y += rctx.maxY;
        } while (--numReps > 0);
    } else {
        do {
            if (rCArray != null) {
                g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
            }
            g.drawLine(x, y, x + size, y);
        } while (--numReps > 0);
    }
    rctx.colorindex = ci;
    g.translate(-rctx.orgX, -rctx.orgY);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:RenderTests.java

示例9: runTest

import java.awt.Graphics; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
    RenderTests.Context rctx = (RenderTests.Context) ctx;
    int size = rctx.size - 1;
    int x = rctx.initX;
    int y = rctx.initY;
    Graphics g = rctx.graphics;
    g.translate(rctx.orgX, rctx.orgY);
    Color rCArray[] = rctx.colorlist;
    int ci = rctx.colorindex;
    if (rctx.animate) {
        do {
            if (rCArray != null) {
                g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
            }
            g.drawLine(x, y, x, y + size);
            if ((x -= 3) < 0) x += rctx.maxX;
            if ((y -= 1) < 0) y += rctx.maxY;
        } while (--numReps > 0);
    } else {
        do {
            if (rCArray != null) {
                g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
            }
            g.drawLine(x, y, x, y + size);
        } while (--numReps > 0);
    }
    rctx.colorindex = ci;
    g.translate(-rctx.orgX, -rctx.orgY);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:RenderTests.java

示例10: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
    if (!(c instanceof JMenuItem)) {
        return;
    }
    JMenuItem b = (JMenuItem) c;
    ButtonModel model = b.getModel();

    g.translate( x, y );

    if ( c.getParent() instanceof JMenuBar ) {
        if ( model.isArmed() || model.isSelected() ) {
            g.setColor( MetalLookAndFeel.getControlDarkShadow() );
            g.drawLine( 0, 0, w - 2, 0 );
            g.drawLine( 0, 0, 0, h - 1 );
            g.drawLine( w - 2, 2, w - 2, h - 1 );

            g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
            g.drawLine( w - 1, 1, w - 1, h - 1 );

            g.setColor( MetalLookAndFeel.getMenuBackground() );
            g.drawLine( w - 1, 0, w - 1, 0 );
        }
    } else {
        if (  model.isArmed() || ( c instanceof JMenu && model.isSelected() ) ) {
            g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
            g.drawLine( 0, 0, w - 1, 0 );

            g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
            g.drawLine( 0, h - 1, w - 1, h - 1 );
        } else {
            g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
            g.drawLine( 0, 0, 0, h - 1 );
        }
    }

    g.translate( -x, -y );
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:MetalBorders.java

示例11: paintBase

import java.awt.Graphics; //导入方法依赖的package包/类
private void paintBase(InstancePainter painter) {
	Direction facing = painter.getAttributeValue(StdAttr.FACING);
	Location loc = painter.getLocation();
	int x = loc.getX();
	int y = loc.getY();
	Graphics g = painter.getGraphics();
	g.translate(x, y);
	double rotate = 0.0;
	if (facing != Direction.EAST && g instanceof Graphics2D) {
		rotate = -facing.toRadians();
		((Graphics2D) g).rotate(rotate);
	}

	GraphicsUtil.switchToWidth(g, 2);
	int[] xp = new int[4];
	int[] yp = new int[4];
	xp[0] = 0;
	yp[0] = 0;
	xp[1] = -19;
	yp[1] = -7;
	xp[2] = -19;
	yp[2] = 7;
	xp[3] = 0;
	yp[3] = 0;
	g.drawPolyline(xp, yp, 4);

	if (rotate != 0.0) {
		((Graphics2D) g).rotate(-rotate);
	}
	g.translate(-x, -y);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:32,代码来源:Buffer.java

示例12: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y) {
    Color oldColor = g.getColor();
    g.translate(x, y);

    g.setColor(color);
    g.fillRect(0, 0, ICON_SIZE.width, ICON_SIZE.height);

    g.setColor(Color.black);
    g.drawRect(0, 0, ICON_SIZE.width, ICON_SIZE.height);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:14,代码来源:ColorChooserButton.java

示例13: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y,
                        int width, int height) {
    if (!(c instanceof JToolBar)) {
        return;
    }
    g.translate(x, y);

    XPStyle xp = XPStyle.getXP();
    if (xp != null) {
        Border xpBorder = xp.getBorder(c, Part.TP_TOOLBAR);
        if (xpBorder != null) {
            xpBorder.paintBorder(c, g, 0, 0, width, height);
        }
    }
    if (((JToolBar)c).isFloatable()) {
        boolean vertical = ((JToolBar)c).getOrientation() == VERTICAL;

        if (xp != null) {
            Part part = vertical ? Part.RP_GRIPPERVERT : Part.RP_GRIPPER;
            Skin skin = xp.getSkin(c, part);
            int dx, dy, dw, dh;
            if (vertical) {
                dx = 0;
                dy = 2;
                dw = width - 1;
                dh = skin.getHeight();
            } else {
                dw = skin.getWidth();
                dh = height - 1;
                dx = c.getComponentOrientation().isLeftToRight() ? 2 : (width-dw-2);
                dy = 0;
            }
            skin.paintSkin(g, dx, dy, dw, dh, State.NORMAL);

        } else {

            if (!vertical) {
                if (c.getComponentOrientation().isLeftToRight()) {
                    g.setColor(shadow);
                    g.drawLine(4, 3, 4, height - 4);
                    g.drawLine(4, height - 4, 2, height - 4);

                    g.setColor(highlight);
                    g.drawLine(2, 3, 3, 3);
                    g.drawLine(2, 3, 2, height - 5);
                } else {
                    g.setColor(shadow);
                    g.drawLine(width - 3, 3, width - 3, height - 4);
                    g.drawLine(width - 4, height - 4, width - 4, height - 4);

                    g.setColor(highlight);
                    g.drawLine(width - 5, 3, width - 4, 3);
                    g.drawLine(width - 5, 3, width - 5, height - 5);
                }
            } else { // Vertical
                g.setColor(shadow);
                g.drawLine(3, 4, width - 4, 4);
                g.drawLine(width - 4, 2, width - 4, 4);

                g.setColor(highlight);
                g.drawLine(3, 2, width - 4, 2);
                g.drawLine(3, 2, 3, 3);
            }
        }
    }

    g.translate(-x, -y);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:69,代码来源:WindowsBorders.java

示例14: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {

            g.translate(x,y);

            int messageType = JOptionPane.PLAIN_MESSAGE;
            if (c instanceof JInternalFrame) {
                Object obj = ((JInternalFrame) c).getClientProperty(
                              "JInternalFrame.messageType");
                if (obj instanceof Integer) {
                    messageType = (Integer) obj;
                }
            }

            Color borderColor;

            switch (messageType) {
            case(JOptionPane.ERROR_MESSAGE):
                borderColor = UIManager.getColor(
                    "OptionPane.errorDialog.border.background");
                break;
            case(JOptionPane.QUESTION_MESSAGE):
                borderColor = UIManager.getColor(
                    "OptionPane.questionDialog.border.background");
                break;
            case(JOptionPane.WARNING_MESSAGE):
                borderColor = UIManager.getColor(
                    "OptionPane.warningDialog.border.background");
                break;
            case(JOptionPane.INFORMATION_MESSAGE):
            case(JOptionPane.PLAIN_MESSAGE):
            default:
                borderColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
                break;
            }

            g.setColor(borderColor);

              // Draw outermost lines
              g.drawLine( 1, 0, w-2, 0);
              g.drawLine( 0, 1, 0, h-2);
              g.drawLine( w-1, 1, w-1, h-2);
              g.drawLine( 1, h-1, w-2, h-1);

              // Draw the bulk of the border
              for (int i = 1; i < 3; i++) {
                  g.drawRect(i, i, w-(i*2)-1, h-(i*2)-1);
              }

            g.translate(-x,-y);

        }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:52,代码来源:MetalBorders.java

示例15: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y) {

            Color color = c == null ? Color.gray
                                    : c.getBackground();

            // In a compound sort, make each succesive triangle 20%
            // smaller than the previous one.
            int dx = (int) (size / 2 * Math.pow(0.8, priority));
            int dy = descending ? dx
                                : -dx;

            // Align icon (roughly) with font baseline.
            y = y + 5 * size / 6 + (descending ? -dy
                                               : 0);

            int shift = descending ? 1
                                   : -1;

            g.translate(x, y);

            // Right diagonal.
            g.setColor(color.darker());
            g.drawLine(dx / 2, dy, 0, 0);
            g.drawLine(dx / 2, dy + shift, 0, shift);

            // Left diagonal.
            g.setColor(color.brighter());
            g.drawLine(dx / 2, dy, dx, 0);
            g.drawLine(dx / 2, dy + shift, dx, shift);

            // Horizontal line.
            if (descending) {
                g.setColor(color.darker().darker());
            } else {
                g.setColor(color.brighter().brighter());
            }

            g.drawLine(dx, 0, 0, 0);
            g.setColor(color);
            g.translate(-x, -y);
        }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:42,代码来源:TableSorter.java


注:本文中的java.awt.Graphics.translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。