|
|
@ -2,9 +2,6 @@ package com.fr.design.foldablepane; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxUtilities; |
|
|
|
|
|
|
|
import com.fr.stable.OperatingSystem; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JFrame; |
|
|
|
import javax.swing.JFrame; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
@ -14,9 +11,7 @@ import java.awt.Font; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.Image; |
|
|
|
import java.awt.Image; |
|
|
|
import java.awt.RenderingHints; |
|
|
|
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Created by MoMeak on 2017/7/5. |
|
|
|
* Created by MoMeak on 2017/7/5. |
|
|
@ -64,29 +59,20 @@ public class HeaderPane extends JPanel { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void paintComponent(Graphics g) { |
|
|
|
protected void paintComponent(Graphics g) { |
|
|
|
Graphics2D g2d = (Graphics2D) g.create(); |
|
|
|
Graphics2D g2d = (Graphics2D) g.create(); |
|
|
|
//mac下抗锯齿处理
|
|
|
|
|
|
|
|
if(OperatingSystem.isMacOS()){ |
|
|
|
|
|
|
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
|
|
|
|
|
|
|
RenderingHints.VALUE_ANTIALIAS_ON); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BufferedImage panelImage = createPanelImage(); |
|
|
|
BufferedImage panelImage = createPanelImage(); |
|
|
|
g2d.drawImage(panelImage, null, 0, 0); |
|
|
|
g2d.drawImage(panelImage, null, 0, 0); |
|
|
|
|
|
|
|
GraphHelper.applyRenderingHints(g2d); |
|
|
|
GraphHelper.drawString(g2d, this.title, TITLE_X, headHeight - fontSize / 2 - 1); |
|
|
|
GraphHelper.drawString(g2d, this.title, TITLE_X, headHeight - fontSize / 2 - 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private BufferedImage createPanelImage() { |
|
|
|
private BufferedImage createPanelImage() { |
|
|
|
BufferedImage panelImage = new BufferedImage(getWidth(), headHeight, BufferedImage.TYPE_INT_ARGB); |
|
|
|
BufferedImage panelImage = new BufferedImage(getWidth(), headHeight, BufferedImage.TYPE_INT_ARGB); |
|
|
|
Graphics2D g2d = panelImage.createGraphics(); |
|
|
|
Graphics2D g2d = panelImage.createGraphics(); |
|
|
|
|
|
|
|
|
|
|
|
g2d.setColor(isPressed ? UIConstants.POPUP_TITLE_BACKGROUND : UIConstants.COMPONENT_BACKGROUND_COLOR); |
|
|
|
g2d.setColor(isPressed ? UIConstants.POPUP_TITLE_BACKGROUND : UIConstants.COMPONENT_BACKGROUND_COLOR); |
|
|
|
headWidth = this.getWidth(); |
|
|
|
headWidth = this.getWidth(); |
|
|
|
g2d.fillRect(0, 0, headWidth, headHeight); |
|
|
|
g2d.fillRect(0, 0, headWidth, headHeight); |
|
|
|
g2d.setFont(new Font("SimSun", 0, fontSize)); |
|
|
|
g2d.setFont(new Font("SimSun", 0, fontSize)); |
|
|
|
g2d.setPaint(bgColor); |
|
|
|
g2d.setPaint(bgColor); |
|
|
|
Map<?, ?> desktopHints = RSyntaxUtilities.getDesktopAntiAliasHints(); |
|
|
|
|
|
|
|
if (desktopHints != null) { |
|
|
|
|
|
|
|
g2d.setRenderingHints(desktopHints); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int leftWdith = headWidth - LEFT_X; |
|
|
|
int leftWdith = headWidth - LEFT_X; |
|
|
|
if (this.isShow) { |
|
|
|
if (this.isShow) { |
|
|
|
image = UIConstants.DRAG_DOWN_SELECTED_SMALL; |
|
|
|
image = UIConstants.DRAG_DOWN_SELECTED_SMALL; |
|
|
|