metacitycrux.java
来自「java jdk 1.4的源码」· Java 代码 · 共 852 行 · 第 1/3 页
JAVA
852 行
<image filename="active-maximize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ active_button_prelight(g, w, h); g.drawImage(getImage("active-maximize-button"), x+2, y+2, w-4, h-4, null); } else { /* <include name="active_button"/> <image filename="active-maximize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ active_button(g, w, h); g.drawImage(getImage("active-maximize-button"), x+2, y+2, w-4, h-4, null); } } else if (buttonName.equals("InternalFrameTitlePane.closeButton")) { if ((buttonState & SynthConstants.PRESSED) != 0) { /* <include name="active_button_pressed"/> <image filename="active-close-button.png" x="2" y="2" width="width-4" height="height-4"/> */ active_button_pressed(g, w, h); g.drawImage(getImage("active-close-button"), x+2, y+2, w-4, h-4, null); } else if ((buttonState & SynthConstants.MOUSE_OVER) != 0) { /* <include name="active_button_prelight"/> <image filename="active-close-button.png" x="2" y="2" width="width-4" height="height-4"/> */ active_button_prelight(g, w, h); g.drawImage(getImage("active-close-button"), x+2, y+2, w-4, h-4, null); } else { /* <include name="active_button"/> <image filename="active-close-button.png" x="2" y="2" width="width-4" height="height-4"/> */ active_button(g, w, h); g.drawImage(getImage("active-close-button"), x+2, y+2, w-4, h-4, null); } } } } private void paintTitleBar(Graphics g, int width, int height, boolean active, JInternalFrame frame, JComponent titlePane) { Image leftTopBorder = getImage("left-top-border", active); Image topCenterLeft = getImage("top-center-left", active); Image topCenterRight = getImage("top-center-right", active); Image rightTopBorder = getImage("right-top-border", active); Image topCenterMidLeft = getImage("top-center-mid-left", active); Image topCenterMidRight = getImage("top-center-mid-right", active); Image topCenterMid = getImage("top-center-mid", active); FrameGeometry gm = getFrameGeometry(); FontMetrics fm = g.getFontMetrics(); int title_width = calculateTitleWidth(frame, titlePane, fm); int x, y, w, h; Image object; if (!active) { /* <image filename="inactive-left-top-border.png" x="0" y="0" width="object_width" height="height"/> */ object = leftTopBorder; x = 0; y = 0; w = object.getWidth(null); h = height; g.drawImage(object, x, y, w, h, null); /* <image filename="inactive-right-top-border.png" x="width - object_width" y="0" width="object_width" height="height"/> */ object = rightTopBorder; x = width - object.getWidth(null); y = 0; w = object.getWidth(null); h = height; g.drawImage(object, x, y, w, h, null); /* <image filename="inactive-top-center-left.png" x="4" y="0" width="(left_width + ButtonWidth + IconTitleSpacing + title_width) `min` (width - right_width - 3 * ButtonWidth - CenterTitlePieceWidth * height / 22 - 3)" height="height"/> */ object = topCenterLeft; x = 4; y = 0; w = Math.min(gm.left_width + ButtonWidth + IconTitleSpacing + title_width, width - gm.right_width - 3 * ButtonWidth - CenterTitlePieceWidth * height / 22 - 3); h = height; g.drawImage(object, x, y, w, h, null); /* <image filename="inactive-top-center-mid.png" x="((left_width + ButtonWidth + IconTitleSpacing + title_width) `min` (width - object_width * height / 22 - right_width - 3 * ButtonWidth)) + 1" y="0" width="object_width * height / 22" height="height"/> */ object = topCenterMid; if (topCenterMid == null) { object = topCenterMidLeft; } x = Math.min(gm.left_width + ButtonWidth + IconTitleSpacing + title_width, width - object.getWidth(null) * height / 22 - gm.right_width - 3 * ButtonWidth) + 1; y = 0; w = object.getWidth(null) * height / 22; h = height; g.drawImage(object, x, y, w, h, null); if (topCenterMid == null) { object = topCenterMidRight; g.drawImage(object, x, y, w, h, null); } /* <image filename="inactive-top-center-right.png" x="((left_width + ButtonWidth + IconTitleSpacing + title_width + CenterTitlePieceWidth * height / 22) `min` (width - 3 * ButtonWidth - right_width)) + 1" y="0" width="(width - title_width - left_width - ButtonWidth - IconTitleSpacing - CenterTitlePieceWidth * height / 22 - right_width) `max` (3 * ButtonWidth)" height="height"/> */ object = topCenterRight; x = Math.min(gm.left_width + ButtonWidth + IconTitleSpacing + title_width + CenterTitlePieceWidth * height / 22, width - 3 * ButtonWidth - gm.right_width) + 1; y = 0; w = Math.max(width - title_width - gm.left_width - ButtonWidth - IconTitleSpacing - CenterTitlePieceWidth * height / 22 - gm.right_width, 3 * ButtonWidth); h = height; g.drawImage(object, x, y, w, h, null); } else { /* <image filename="active-left-top-border.png" colorize="gtk:bg[SELECTED]" x="0" y="0" width="object_width" height="height"/> */ object = getImage("active-left-top-border", getColor(SELECTED, GTKColorType.BACKGROUND)); x = 0; y = 0; w = object.getWidth(null); h = height; g.drawImage(object, x, y, w, h, null); /* <image filename="active-right-top-border.png" x="width - object_width" y="0" width="object_width" height="height"/> */ object = rightTopBorder; x = width - object.getWidth(null); y = 0; w = object.getWidth(null); h = height; g.drawImage(object, x, y, w, h, null); /* <image filename="active-top-center-left.png" colorize="gtk:bg[SELECTED]" x="4" y="0" width="(left_width + ButtonWidth + IconTitleSpacing + title_width) `min` (width - right_width - 3 * ButtonWidth - CenterTitlePieceWidth * height / 22 - 3)" height="height"/> */ object = getImage("active-top-center-left", getColor(SELECTED, GTKColorType.BACKGROUND)); x = 4; y = 0; w = Math.min(gm.left_width + ButtonWidth + IconTitleSpacing + title_width, width - gm.right_width - 3 * ButtonWidth - CenterTitlePieceWidth * height / 22 - 3); h = height; g.drawImage(object, x, y, w, h, null); /* <image filename="active-top-center-mid-left.png" colorize="gtk:bg[SELECTED]" x="((left_width + ButtonWidth + IconTitleSpacing + title_width) `min` (width - object_width * height / 22 - right_width - 3 * ButtonWidth)) + 1" y="0" width="object_width * height / 22" height="height"/> */ object = getImage("active-top-center-mid-left", getColor(SELECTED, GTKColorType.BACKGROUND)); x = Math.min(gm.left_width + ButtonWidth + IconTitleSpacing + title_width, width - object.getWidth(null) * height / 22 - gm.right_width - 3 * ButtonWidth) + 1; y = 0; w = object.getWidth(null) * height / 22; h = height; g.drawImage(object, x, y, w, h, null); /* <image filename="active-top-center-mid-right.png" x="((left_width + ButtonWidth + IconTitleSpacing + title_width) `min` (width - object_width * height / 22 - right_width - 3 * ButtonWidth)) + 1" y="0" width="object_width * height / 22" height="height"/> */ object = topCenterMidRight; x = Math.min(gm.left_width + ButtonWidth + IconTitleSpacing + title_width, width - object.getWidth(null) * height / 22 - gm.right_width - 3 * ButtonWidth) + 1; y = 0; w = object.getWidth(null) * height / 22; h = height; g.drawImage(object, x, y, w, h, null); /* <image filename="active-top-center-right.png" x="((left_width + ButtonWidth + IconTitleSpacing + title_width + CenterTitlePieceWidth * height / 22) `min` (width - 3 * ButtonWidth - right_width)) + 1" y="0" width="(width - title_width - left_width - ButtonWidth - IconTitleSpacing - CenterTitlePieceWidth * height / 22 - right_width) `max` (3 * ButtonWidth)" height="height"/> */ object = topCenterRight; x = Math.min(gm.left_width + ButtonWidth + IconTitleSpacing + title_width + CenterTitlePieceWidth * height / 22, width - 3 * ButtonWidth - gm.right_width) + 1; y = 0; w = Math.max(width - title_width - gm.left_width - ButtonWidth - IconTitleSpacing - CenterTitlePieceWidth * height / 22 - gm.right_width, 3 * ButtonWidth); h = height; g.drawImage(object, x, y, w, h, null); } Color textColor; if (!active) { /* <piece position="title"> <draw_ops> <title color="white" x="IconTitleSpacing" y="0"/> </draw_ops> </piece> */ textColor = Color.white; } else { /* <piece position="title"> <draw_ops> <title color="white" x="IconTitleSpacing" y="((height - title_height) / 2) `max` 0"/> </draw_ops> </piece> */ textColor = Color.white; } String title = frame.getTitle(); if (title != null) { // Center text vertically. int baseline = (height + fm.getAscent() - fm.getLeading() - fm.getDescent()) / 2; int titleX; if (frame.getComponentOrientation().isLeftToRight()) { title = getTitle(title, fm, title_width); titleX = gm.left_width + ButtonWidth + IconTitleSpacing; } else { titleX = width - gm.right_width - ButtonWidth - 2 - SwingUtilities.computeStringWidth(fm, title); } g.setColor(textColor); g.drawString(title, titleX, baseline); } } private int calculateTitleWidth(JInternalFrame frame, JComponent titlePane, FontMetrics fm) { FrameGeometry gm = getFrameGeometry(); String title = frame.getTitle(); if (title != null) { JComponent button = null; if (frame.isIconifiable()) { button = findChild(titlePane, "InternalFrameTitlePane.iconifyButton"); } if (button == null && frame.isMaximizable()) { button = findChild(titlePane, "InternalFrameTitlePane.maximizeButton"); } if (button == null && frame.isClosable()) { button = findChild(titlePane, "InternalFrameTitlePane.closeButton"); } int buttonX = (button != null) ? button.getX() : (titlePane.getWidth() - gm.right_titlebar_edge); return Math.min(SwingUtilities.computeStringWidth(fm, title), buttonX - (gm.left_width + ButtonWidth + IconTitleSpacing) - 3); } return 0; } private String getTitle(String text, FontMetrics fm, int availTextWidth) { if ((text == null) || (text.equals(""))) { return ""; } int textWidth = SwingUtilities.computeStringWidth(fm, text); String clipString = "..."; if (textWidth > availTextWidth) { int totalWidth = SwingUtilities.computeStringWidth(fm, clipString); int nChars;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?