@ -1,6 +1,7 @@
package com.fr.design.mainframe ;
import com.fr.base.BaseUtils ;
import com.fine.theme.icon.LazyIcon ;
import com.formdev.flatlaf.ui.FlatUIUtils ;
import com.fr.base.GraphHelper ;
import com.fr.base.svg.IconUtils ;
import com.fr.base.theme.ReportTheme ;
@ -19,7 +20,6 @@ import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane ;
import com.fr.design.utils.gui.GUICoreUtils ;
import com.fr.general.ComparatorUtils ;
import com.fr.general.IOUtils ;
import com.fr.main.impl.WorkBook ;
import com.fr.poly.PolyDesigner ;
import com.fr.report.poly.PolyWorkSheet ;
@ -37,7 +37,7 @@ import java.awt.BorderLayout;
import java.awt.Color ;
import java.awt.Dimension ;
import java.awt.FontMetrics ;
import java.awt.GradientPaint ;
import java.awt.BasicStroke ;
import java.awt.Graphics ;
import java.awt.Graphics2D ;
import java.awt.Point ;
@ -49,8 +49,7 @@ import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent ;
import java.awt.event.MouseListener ;
import java.awt.event.MouseMotionListener ;
import java.awt.geom.GeneralPath ;
import java.awt.geom.Path2D ;
import java.awt.geom.RoundRectangle2D ;
import java.util.ArrayList ;
import java.util.List ;
@ -62,29 +61,32 @@ import java.util.List;
* /
public class SheetNameTabPane extends JComponent implements MouseListener , MouseMotionListener , RemoveListener {
private static final Color LINE_COLOR = new Color ( 0xababab ) ;
private static final Color BORDER_COLOR = UIManager . getColor ( "ZoneBorderColor" ) ;
private static final Color BACKGROUND_COLOR = UIManager . getColor ( "CenterOuterShadowColor" ) ;
private static final Color SELECTED_COLOR = UIManager . getColor ( "DesignerSpaceColor" ) ;
private static final Color FONT_COLOR = UIManager . getColor ( "DarkenedFontColor" ) ;
private static final Icon ADD_WORK_SHEET = IconUtils . readIcon ( "/com/fr/design/standard/add_worksheet" ) ;
protected static final Icon ADD_POLY_SHEET = IconUtils . readIcon ( "/com/fr/design/standard/add_polysheet" ) ;
private static final Icon WORK_SHEET_ICON = IconUtils . readIcon ( "/com/fr/design/standard/worksheet" ) ;
private static final Icon POLY_SHEET_ICON = IconUtils . readIcon ( "/com/fr/design/standard/polysheet" ) ;
private static final Icon ADD_WORK_SHEET = new Lazy Icon( "add_worksheet" ) ;
protected static final Icon ADD_POLY_SHEET = new Lazy Icon( "add_polysheet" ) ;
// TODO: 视觉未提供
private static final Icon LEFT_ICON = IconUtils . readIcon ( "/com/fr/design/standard/prepage/pre_page" ) ;
private static final Icon RIGHT_ICON = IconUtils . readIcon ( "/com/fr/design/standard/nextpage/next_page" ) ;
private static final Icon DISABLED_LEFT_ICON = IconUtils . readIcon ( "/com/fr/design/standard/prepage/pre_page_disabled.svg" ) ;
private static final Icon DISABLED_RIGHT_ICON = IconUtils . readIcon ( "/com/fr/design/standard/nextpage/next_page_disabled.svg" ) ;
private static final int NUM = 10 ;
private static final int ICON_SEP_DISTANCE = 8 ;
private static final int TOOLBAR_HEIGHT = 16 ;
private static final int ADD_WIDTH_BY_SHEETNAME = 20 ; //sheet名字的文本到图标边框的距离
private static final int GRID_TOSHEET_RIGHT = 20 ; // 添加grid按钮右侧距sheet面板右侧的距离
private static final int POLY_TOSHEET_LEFT = 30 ; // 添加poly按钮左侧距sheet面板右侧的距离
private static final int POLY_TOSHEET_RIGHT = 50 ; // 添加poly按钮右侧距sheet面板右侧的距离
private static final int SHEET_ICON_GAP = 5 ; // 每个sheet图标之间的距离
private static final int GRAP = 12 ; // 给两个添加按钮与其他组件预留的间隔
private static final int LEFT_CORNOR = 0 ; // 左角落.
private static final int RIGHT_CORNOR = 0 ; // 右角落
private static final int ICON_SEP_DISTANCE = UIManager . getInt ( "South.SheetIconSepDistance" ) ;
private static final int SHEET_ICON_GAP = UIManager . getInt ( "South.SheetIconGap" ) ; // 每个sheet图标之间的距离
private static final int TOOLBAR_HEIGHT = UIManager . getInt ( "South.SheetBarHeight" ) ;
private static final int ADD_WIDTH_BY_SHEETNAME = UIManager . getInt ( "South.SheetAddWidth" ) ; //sheet名字的文本到图标边框的距离
private static final int TAB_BUTTON_GAP = UIManager . getInt ( "South.SheetTabButtonGap" ) ; // 两个添加按钮与其他组件预留的间隔
private static final int SHEET_TAB_RADIUS = UIManager . getInt ( "South.SheetTabRadius" ) ; // sheet标签栏圆角属性
/ * *
* 左移和右移按钮
@ -158,25 +160,14 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
this . addMouseListener ( this ) ;
this . addMouseMotionListener ( this ) ;
this . setBorder ( null ) ;
this . setForeground ( new Color ( 99 , 99 , 99 ) ) ;
this . setForeground ( FONT_COLOR ) ;
this . setBackground ( BACKGROUND_COLOR ) ;
leftButton = new UIButton ( LEFT_ICON ) {
@Override
public Dimension getPreferredSize ( ) {
return new Dimension ( super . getPreferredSize ( ) . width , TOOLBAR_HEIGHT ) ;
}
} ;
// leftButton.setUI(new UIButtonUI() {
// @Override
// protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) {
// if (isPressed(b) && b.isPressedPainted()) {
// GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), UIConstants.PROPERTY_PANE_BACKGROUND);
// } else if (isRollOver(b)) {
// GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.PROPERTY_PANE_BACKGROUND);
// } else if (b.isNormalPainted()) {
// GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted());
// }
// }
// });
leftButton . set4ToolbarButton ( ) ;
leftButton . setDisabledIcon ( DISABLED_LEFT_ICON ) ;
rightButton = new UIButton ( RIGHT_ICON ) {
@ -185,18 +176,6 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
return new Dimension ( super . getPreferredSize ( ) . width , TOOLBAR_HEIGHT ) ;
}
} ;
// rightButton.setUI(new UIButtonUI() {
// @Override
// protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) {
// if (isPressed(b) && b.isPressedPainted()) {
// GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), UIConstants.PROPERTY_PANE_BACKGROUND);
// } else if (isRollOver(b)) {
// GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.PROPERTY_PANE_BACKGROUND);
// } else if (b.isNormalPainted()) {
// GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted());
// }
// }
// });
rightButton . set4ToolbarButton ( ) ;
rightButton . setDisabledIcon ( DISABLED_RIGHT_ICON ) ;
buttonPane = new JPanel ( new BorderLayout ( 3 , 0 ) ) ;
@ -347,13 +326,11 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
public Icon getAddWorkSheet ( ) {
return ADD_WORK_SHEET ;
}
public Icon getWorkSheetIcon ( ) {
return WORK_SHEET_ICON ;
}
@Override
/ * *
* 画Tab
* /
@Override
public void paintComponent ( Graphics g ) {
super . paintComponent ( g ) ;
isAuthorityEditing = DesignerMode . isAuthorityEditing ( ) ;
@ -366,7 +343,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
double textHeight = this . getSize ( ) . getHeight ( ) - 1 ;
widthArray = calculateWidthArray ( ) ;
int operationWidth = GR AP + getAddWorkSheet ( ) . getIconWidth ( ) + ICON_SEP_DISTANCE + ADD_POLY_SHEET . getIconWidth ( ) ;
int operationWidth = TAB_BUTTON_ GAP + getAddWorkSheet ( ) . getIconWidth ( ) + ICON_SEP_DISTANCE + ADD_POLY_SHEET . getIconWidth ( ) ;
double maxWidth = getWidth ( ) - operationWidth - buttonPane . getWidth ( ) ; // 最大宽度
paintBackgroundAndLine ( g2d , textHeight , maxWidth , charWidth , textAscent ) ;
checkButton ( showCount < widthArray . length ) ;
@ -389,7 +366,6 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
WorkBook workBook = reportComposite . getEditingWorkBook ( ) ;
int reportCount = workBook . getReportCount ( ) ;
double textX = 0 ;
Icon sheeticon ;
for ( int i = scrollIndex ; i < reportCount ; i + + ) {
lastOneIndex = i ;
TemplateReport templateReport = workBook . getTemplateReport ( i ) ;
@ -398,13 +374,11 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
String selectedRoles = ReportAndFSManagePane . getInstance ( ) . getRoleTree ( ) . getSelectedRoleName ( ) ;
isNeedPaintedAuthority = templateReport . getWorkSheetPrivilegeControl ( ) . checkInvisible ( selectedRoles ) ;
}
sheeticon = templateReport instanceof WorkSheet ? getWorkSheetIcon ( ) : POLY_SHEET_ICON ;
String sheetName = workBook . getReportName ( i ) ;
if ( i = = selectedIndex ) {
paintSelectedTab ( g2d , sheeticon , textHeight , textX , sheetName , charWidth , textAscent , isNeedPaintedAuthority ) ;
} else {
paintUnSelectedTab ( g2d , sheeticon , textHeight , textX , sheetName , charWidth , textAscent , i , isNeedPaintedAuthority ) ;
}
boolean selected = i = = selectedIndex ;
paintTab ( g2d , textHeight , textX , sheetName , charWidth , textAscent , i , isNeedPaintedAuthority , selected ) ;
int width = widthArray [ i ] ;
textX + = width + 1 ;
addIconlocation + = width ;
@ -423,7 +397,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
}
// 画两个添加sheet图标
iconLocation = isOvertakeWidth ? ( int ) ( maxWidth ) : addIconlocation + GR AP ;
iconLocation = isOvertakeWidth ? ( int ) ( maxWidth ) : addIconlocation + TAB_BUTTON_ GAP;
paintAddButton ( g2d ) ;
}
@ -433,78 +407,29 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
ADD_POLY_SHEET . paintIcon ( this , g2d , iconLocation + getAddWorkSheet ( ) . getIconWidth ( ) + ICON_SEP_DISTANCE , 3 ) ;
}
/ * *
* 画选中的tab
*
* @param g2d
* @param sheeticon
* @param textHeight
* @param textX
* @param sheetName
* @param charWidth
* @param textAscent
* /
private void paintSelectedTab ( Graphics2D g2d , Icon sheeticon , double textHeight , double textX , String sheetName , int charWidth , int textAscent , boolean isNeedPaintAuthority ) {
double [ ] x = { textX , textX , textX + LEFT_CORNOR , textX + widthArray [ selectedIndex ] - RIGHT_CORNOR , textX + widthArray [ selectedIndex ] + RIGHT_CORNOR } ;
double [ ] y = { 0 , textHeight - LEFT_CORNOR , textHeight , textHeight , 0 } ;
if ( isNeedPaintAuthority ) {
g2d . setPaint ( new GradientPaint ( 1 , 1 , UIConstants . AUTHORITY_SHEET_LIGHT , 1 , getHeight ( ) - 1 , UIConstants . AUTHORITY_SHEET_DARK ) ) ;
} else {
g2d . setPaint ( new GradientPaint ( 1 , 1 , getBackground ( ) , 1 , getHeight ( ) - 1 , getBackground ( ) ) ) ;
}
GeneralPath generalPath = new GeneralPath ( Path2D . WIND_EVEN_ODD , x . length ) ;
generalPath . moveTo ( ( float ) x [ 0 ] , ( float ) y [ 0 ] ) ;
for ( int index = 1 ; index < x . length ; index + + ) {
generalPath . lineTo ( ( float ) x [ index ] , ( float ) y [ index ] ) ;
private void paintTab ( Graphics2D g2d , double textHeight , double textX , String sheetName , int charWidth , int textAscent , int i , boolean isNeedPaintAuthority , boolean isSelected ) {
Color backgroundColor = isSelected ? SELECTED_COLOR : ( isNeedPaintAuthority ? UIConstants . AUTHORITY_SHEET_UNSELECTED : getBackground ( ) ) ;
g2d . setColor ( backgroundColor ) ;
// 绘制圆角矩形背景
if ( isSelected ) {
FlatUIUtils . setRenderingHints ( g2d ) ;
int width = widthArray [ i ] ;
int height = ( int ) textHeight + SHEET_TAB_RADIUS ;
RoundRectangle2D . Double backgroundRect = new RoundRectangle2D . Double ( textX , - 10 , width , height , SHEET_TAB_RADIUS , SHEET_TAB_RADIUS ) ;
g2d . fill ( backgroundRect ) ;
g2d . setColor ( BORDER_COLOR ) ;
g2d . setStroke ( new BasicStroke ( 1 ) ) ;
g2d . draw ( backgroundRect ) ;
}
generalPath . closePath ( ) ;
g2d . fill ( generalPath ) ;
sheeticon . paintIcon ( this , g2d , ( int ) textX + charWidth , 2 ) ;
// peter:画字符
g2d . setPaint ( getForeground ( ) ) ;
GraphHelper . drawString ( g2d , sheetName , ( int ) textX + charWidth + 14 , textAscent ) ;
}
/ * *
* 画不是选中状态的tab
*
* @param g2d
* @param sheetIcon
* @param textHeight
* @param textX
* @param sheetName
* @param charWidth
* @param textAscent
* @param i
* /
private void paintUnSelectedTab ( Graphics2D g2d , Icon sheetIcon , double textHeight , double textX , String sheetName , int charWidth , int textAscent , int i , boolean isNeedPaintAuthority ) {
Color tabBackground = UIConstants . COMBOBOX_BTN_NORMAL ;
int width = widthArray [ i ] ;
double [ ] x = { textX , textX , textX + LEFT_CORNOR , textX + width - RIGHT_CORNOR , textX + width , textX + width } ;
double [ ] y = { 0 , textHeight - LEFT_CORNOR , textHeight , textHeight , textHeight - RIGHT_CORNOR , 0 } ;
if ( isNeedPaintAuthority ) {
g2d . setPaint ( UIConstants . AUTHORITY_SHEET_UNSELECTED ) ;
} else {
g2d . setPaint ( getBackground ( ) ) ;
}
GeneralPath generalPath = new GeneralPath ( Path2D . WIND_EVEN_ODD , x . length ) ;
generalPath . moveTo ( ( float ) x [ 0 ] , ( float ) y [ 0 ] ) ;
for ( int index = 1 ; index < x . length ; index + + ) {
generalPath . lineTo ( ( float ) x [ index ] , ( float ) y [ index ] ) ;
}
generalPath . closePath ( ) ;
g2d . fill ( generalPath ) ;
g2d . setPaint ( LINE_COLOR ) ;
double startX = textX > 0 ? textX - 1 : textX ;
g2d . drawRect ( ( int ) startX , 0 , width , ( int ) textHeight ) ;
sheetIcon . paintIcon ( this , g2d , ( int ) textX + charWidth , 2 ) ;
g2d . setPaint ( getForeground ( ) ) ;
// REPORT-40495 之前的g2d.drawString(),在windows下默认宋体时,无法绘制韩文字符,而GraphHelper的drawString中对韩文做了额外处理,可以绘制韩文字符
GraphHelper . drawString ( g2d , sheetName , ( int ) textX + charWidth + 14 , textAscent ) ;
// 绘制文本
g2d . setColor ( getForeground ( ) ) ;
GraphHelper . drawString ( g2d , sheetName , ( int ) textX + charWidth + 4 , textAscent + 2 ) ;
}
/ * *
@ -529,12 +454,8 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
for ( int i = 0 ; i < selectedIndex ; i + + ) {
totalWidth + = widthArray [ i ] ;
}
int distance = startPointX - totalWidth ;
int [ ] x = { ( int ) lastPoint . getX ( ) - distance , ( int ) lastPoint . getX ( ) - distance , ( int ) lastPoint . getX ( ) - distance + width , ( int ) lastPoint . getX ( ) + width - distance } ;
int [ ] y = { 0 , ( int ) ( textHeight ) , ( int ) ( textHeight ) , 0 } ;
g2d . drawPolygon ( x , y , 4 ) ;
// peter:画字符
g2d . setPaint ( getForeground ( ) ) ;
// richie:把当前选中的workSheet的名字画到鼠标拖动产生的图形上.
@ -799,7 +720,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
protected abstract class SheetInsertAction extends UpdateAction {
SheetInsertAction ( ) {
this . setName ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Report_Insert" ) + getTemplateReportType ( ) ) ;
this . setSmallIcon ( IOUtils . read Icon( "/com/fr/base/images/cell/control/ add.png " ) ) ;
this . setSmallIcon ( new Lazy Icon( "add" ) ) ;
}
@Override
@ -838,7 +759,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
widthArray = calculateWidthArray ( ) ;
int width = widthArray [ i ] ;
textX + = width + 1 ;
int operationWidth = GR AP + getAddWorkSheet ( ) . getIconWidth ( ) + ICON_SEP_DISTANCE + ADD_POLY_SHEET . getIconWidth ( ) ;
int operationWidth = TAB_BUTTON_ GAP + getAddWorkSheet ( ) . getIconWidth ( ) + ICON_SEP_DISTANCE + ADD_POLY_SHEET . getIconWidth ( ) ;
double maxWidth = getWidth ( ) - operationWidth - buttonPane . getWidth ( ) ; // 最大宽度
if ( i < widthArray . length - 1 & & textX + widthArray [ i + 1 ] + 1 > maxWidth ) {
isOvertakeWidth = true ;
@ -890,7 +811,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
private class RemoveSheetAction extends UpdateAction {
RemoveSheetAction ( ) {
this . setName ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Remove" ) ) ;
this . setSmallIcon ( BaseUtils . read Icon( "/com/fr/base/images/cell/control/ remove.png " ) ) ;
this . setSmallIcon ( new Lazy Icon( "remove" ) ) ;
}
@Override
@ -947,7 +868,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
private class RenameSheetAction extends UpdateAction {
RenameSheetAction ( ) {
this . setName ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Report_Rename" ) ) ;
this . setSmallIcon ( BaseUtils . read Icon( "/com/fr/base/images/cell/control/ rename.png " ) ) ;
this . setSmallIcon ( new Lazy Icon( "rename" ) ) ;
}
@Override
@ -981,7 +902,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
private class CopySheetAction extends UpdateAction {
CopySheetAction ( ) {
this . setName ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Copy" ) ) ;
this . setSmallIcon ( IOUtils . read Icon( "/com/fr/design/images/m_edit/ copy.png " ) ) ;
this . setSmallIcon ( new Lazy Icon( "copy" ) ) ;
}
@Override