Browse Source

REPORT-58395【主题切换】frm主题配置组件标题图案以后,左侧预览图不生效

fix-lag
kerry 3 years ago
parent
commit
212cd97557
  1. 1
      designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java
  2. 32
      designer-base/src/main/java/com/fr/design/style/background/BackgroundJComponent.java
  3. 46
      designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java

1
designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java

@ -40,7 +40,6 @@ public abstract class AbstractSelectBox<T> extends AbstractPopBox implements Mou
displayComponent = new BackgroundJComponent();
displayComponent.setEmptyBackground();
displayComponent.setBorder(new TriggleLineBorder());
triggleButton = new UIButton(UIConstants.ARROW_DOWN_ICON) {
public boolean shouldResponseChangeListener() {
return false;

32
designer-base/src/main/java/com/fr/design/style/background/BackgroundJComponent.java

@ -1,10 +1,12 @@
package com.fr.design.style.background;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.geom.Rectangle2D;
import javax.swing.JComponent;
import com.fr.design.border.UIRoundedBorder;
import com.fr.general.Background;
/**
@ -18,7 +20,7 @@ public class BackgroundJComponent extends JComponent {
protected Background background ;
public BackgroundJComponent() {
this.setBorder(new UIRoundedBorder(Color.decode("#999999"), 2, 2));
}
public BackgroundJComponent(Background background) {
@ -29,16 +31,32 @@ public class BackgroundJComponent extends JComponent {
super.paint(g);
if(background != null && this.getSize().getWidth() > 0 && this.getSize().getHeight() > 0) {
background.paint(g, new Rectangle2D.Double(1, 1, this.getSize().getWidth() - 2,
this.getSize().getHeight() - 2));
}
background.paint(g, new Rectangle2D.Double(2, 2, this.getSize().getWidth() - 4,
this.getSize().getHeight() - 4));
}
}
public void setEmptyBackground() {
@Override
protected void paintBorder(Graphics g) {
// Color oldColor = g.getColor();
// Border border = getBorder();
// if (border != null) {
// border.paintBorder(this, g, 0, 0, getWidth(), getHeight());
// }
super.paintBorder(g);
}
public void setEmptyBackground() {
this.background = null;
}
public void setSelfBackground(Background background) {
this.background = background;
}
@Override
public Insets getInsets() {
return new Insets(0,0,0,0);
}
}

46
designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java

@ -39,6 +39,8 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
private static final long serialVersionUID = -8634152305687249392L;
private static final float BRIGHTNESS_VALUE = 0.15F;
private static final float PURITY_VALUE = 0.1F;
private static final int WIDTH = 197;
private static final int HEIGHT = 250;
private FineColor color = null; // color
// color setting action.
@ -49,9 +51,6 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
private boolean isSupportThemeColor;
public final static int TRANSPARENT_WINDOW_HEIGHT = 165;
public final static int WINDOW_HEIGHT = 150;
// 最近使用颜色
private final NewUsedColorPane usedColorPane;
private final JPanel menuColorPane;
@ -84,10 +83,12 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
this.add(centerPane, BorderLayout.CENTER);
menuColorPane = getMenuColorPane();
centerPane.add(menuColorPane);
if(isSupportThemeColor){
initThemeColorPane();
JPanel themePane = initThemeColorPane();
centerPane.add(themePane);
}else {
centerPane.add(menuColorPane);
initMenuColorPane();
}
@ -138,8 +139,14 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
return jPanel;
}
private void initThemeColorPane(){
private JPanel initThemeColorPane(){
menuColorPane.removeAll();
JPanel themeColorPane = new JPanel(new BorderLayout(0, 5));
themeColorPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
themeColorPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Theme_Color")), BorderLayout.CENTER);
themeColorPane.add(menuColorPane, BorderLayout.SOUTH);
menuColorPane.setLayout(new BorderLayout(0, 10));
JPanel northPane = new JPanel(new GridLayout(1, 8, 3, 0));
JPanel centerPane = new JPanel(new GridLayout(1, 8, 3, 0));
@ -147,10 +154,6 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
menuColorPane.add(centerPane, BorderLayout.CENTER);
Color[] colorArray = new Color[] {
// 2列灰度色
Color.decode("#B3B3B3"),
Color.decode("#808080"),
// 8列主题色
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
@ -160,13 +163,17 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
// 2列灰度色
Color.decode("#808080"),
Color.decode("#B3B3B3"),
};
if (themeColorCellGrid == null) {
themeColorCellGrid = new ColorCell[colorArray.length][5];
for (int i = 0; i < colorArray.length; i++) {
ColorCell[] colorCellColumn = new ColorCell[5];
boolean isDefaultColor = (i == 0 || i == 1);
boolean isDefaultColor = (i == colorArray.length - 1 || i == colorArray.length - 2);
Color color = colorArray[i];
colorCellColumn[0] = createFineColorCell(color, isDefaultColor, i, 2);
colorCellColumn[2] = createFineColorCell(color = saturationDown(color, isDefaultColor, true), isDefaultColor, i, 1);
@ -191,6 +198,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
}
refreshThemeMenuColorPane();
return themeColorPane;
}
private void refreshThemeMenuColorPane() {
@ -210,14 +218,14 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
return;
}
for (int i = 2; i < themeColorCellGrid.length; i++) {
Color color = standardColors.get(i - 2);
for (int i = 0; i < themeColorCellGrid.length - 2; i++) {
Color color = standardColors.get(i);
themeColorCellGrid[i][0].setColor(color);
themeColorCellGrid[i][2].setColor(color = saturationDown(color, false, true));
themeColorCellGrid[i][1].setColor(saturationDown(color, false, true));
color = standardColors.get(i - 2);
color = standardColors.get(i);
themeColorCellGrid[i][3].setColor(color = saturationDown(color, false, false));
themeColorCellGrid[i][4].setColor(saturationDown(color, false, false));
}
@ -225,7 +233,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
private FineColorCell createFineColorCell(Color color, boolean isDefaultColor, int x, int y) {
return isDefaultColor ? new FineColorCell(color, this) : new FineColorCell(color, this, x - 2, y);
return isDefaultColor ? new FineColorCell(color, this) : new FineColorCell(color, this, x, y);
}
/**
@ -375,10 +383,14 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
@Override
public Dimension getPreferredSize() {
int height = HEIGHT;
if (isSupportTransparent) {
return new Dimension(197, 265);
height += 15;
}
if (isSupportThemeColor) {
height += 25;
}
return new Dimension(197, 250);
return new Dimension(WIDTH, height);
}
/**

Loading…
Cancel
Save