Browse Source

Merge pull request #680 in DESIGN/design from ~KERRY/design_10.0:release/10.0 to release/10.0

* commit 'a5a4dc4db6e501187ac58340735969589815c6d2':
  REPORT-13477 移动端属性》决策报表》tab样式》tab标题过长的时候,上菜单式/下菜单式的预览效果异常
bugfix/10.0
kerry 6 years ago
parent
commit
ed6530242d
  1. 6
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleDefinePane.java
  2. 6
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java
  3. 6
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UpMenuStyleDefinePane.java
  4. 15
      designer-base/src/main/java/com/fr/design/mainframe/widget/preview/MobileTemplatePreviewPane.java

6
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleDefinePane.java

@ -95,9 +95,9 @@ public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane
int ascentHeight = fm.getAscent(); int ascentHeight = fm.getAscent();
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText(); String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(widgetName); int width = fm.stringWidth(displayName);
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight); g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight);
if (i == 0) { if (i == 0) {
g2d.setStroke(new BasicStroke(2.0f)); g2d.setStroke(new BasicStroke(2.0f));
g2d.drawLine(0, panelHeight - 1, eachWidth, panelHeight - 1); g2d.drawLine(0, panelHeight - 1, eachWidth, panelHeight - 1);

6
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java

@ -163,8 +163,8 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground()); g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText(); String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(widgetName); int width = fm.stringWidth(displayName);
if(i == 0){ if(i == 0){
Color oldColor = g2d.getColor(); Color oldColor = g2d.getColor();
g2d.setColor(this.getSelectColor()); g2d.setColor(this.getSelectColor());
@ -173,7 +173,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
} }
Icon icon = new Icon(PAINT_ICON, ICON_PATH); Icon icon = new Icon(PAINT_ICON, ICON_PATH);
g2d.drawImage(IconManager.getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null); g2d.drawImage(IconManager.getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null);
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight + ICON_OFFSET + GAP - fontHeight) / 2 + ascent); g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight + ICON_OFFSET + GAP - fontHeight) / 2 + ascent);
Stroke oldStroke = g2d.getStroke(); Stroke oldStroke = g2d.getStroke();
if (splitLine.getLineStyle() != 0) { if (splitLine.getLineStyle() != 0) {
g2d.setColor(splitLine.getColor()); g2d.setColor(splitLine.getColor());

6
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UpMenuStyleDefinePane.java

@ -188,15 +188,15 @@ public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground()); g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText(); String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(widgetName); int width = fm.stringWidth(displayName);
if(i == 0){ if(i == 0){
Color oldColor = g2d.getColor(); Color oldColor = g2d.getColor();
g2d.setColor(this.getSelectColor()); g2d.setColor(this.getSelectColor());
g2d.fillRect(0, 0 ,eachWidth, panelHeight - 2); g2d.fillRect(0, 0 ,eachWidth, panelHeight - 2);
g2d.setColor(oldColor); g2d.setColor(oldColor);
} }
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight); g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight);
Stroke oldStroke = g2d.getStroke(); Stroke oldStroke = g2d.getStroke();
if (i == 0) { if (i == 0) {
g2d.setColor(this.underLine.getColor()); g2d.setColor(this.underLine.getColor());

15
designer-base/src/main/java/com/fr/design/mainframe/widget/preview/MobileTemplatePreviewPane.java

@ -5,6 +5,7 @@ import com.fr.general.cardtag.mobile.TabFontConfig;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Color; import java.awt.Color;
import java.awt.FontMetrics;
public abstract class MobileTemplatePreviewPane extends JPanel { public abstract class MobileTemplatePreviewPane extends JPanel {
private Color initialColor; private Color initialColor;
@ -46,6 +47,20 @@ public abstract class MobileTemplatePreviewPane extends JPanel {
this.setTabFontConfig(templateStyle.getTabFontConfig()); this.setTabFontConfig(templateStyle.getTabFontConfig());
} }
protected String calculateDisplayName(String widgetName, FontMetrics fm, int eachWidth) {
StringBuffer buffer = new StringBuffer();
String result;
for (int i = 0; i < widgetName.length(); i++) {
result = buffer.toString();
buffer.append(widgetName.charAt(i));
if (fm.stringWidth(buffer.toString()) > eachWidth) {
return result;
}
}
return buffer.toString();
}
public void repaint() { public void repaint() {
super.repaint(); super.repaint();
} }

Loading…
Cancel
Save