Browse Source

Grid线颜色

master
hzzz 7 years ago
parent
commit
67cfaaa9d1
  1. 1
      designer/src/com/fr/design/mainframe/ElementCasePane.java
  2. 307
      designer/src/com/fr/grid/Grid.java
  3. 4
      designer/src/com/fr/grid/GridHeader.java

1
designer/src/com/fr/design/mainframe/ElementCasePane.java

@ -390,7 +390,6 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
grid.setDefaultFloatEditor(Image.class, new ImageFloatEditor()); grid.setDefaultFloatEditor(Image.class, new ImageFloatEditor());
DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager();
grid.setGridLineColor(designerEnvManager.getGridLineColor());
grid.setPaginationLineColor(designerEnvManager.getPaginationLineColor()); grid.setPaginationLineColor(designerEnvManager.getPaginationLineColor());
} }

307
designer/src/com/fr/grid/Grid.java

@ -10,7 +10,6 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.fun.GridUIProcessor; import com.fr.design.fun.GridUIProcessor;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.grid.event.CellEditorEvent; import com.fr.grid.event.CellEditorEvent;
@ -36,7 +35,6 @@ import javax.swing.plaf.ComponentUI;
import java.awt.*; import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.util.Date;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
@ -57,7 +55,7 @@ public class Grid extends BaseGridComponent {
transient private TemplateCellElement editingCellElement; transient private TemplateCellElement editingCellElement;
private boolean showGridLine = true; private boolean showGridLine = true;
private Color gridLineColor = new Color(0xf0f0f3); // line color. private Color gridLineColor = UIConstants.RULER_LINE_COLOR; // line color.
private boolean isShowPaginateLine = true; private boolean isShowPaginateLine = true;
private Color paginationLineColor = Color.RED; // line color of paper private Color paginationLineColor = Color.RED; // line color of paper
@ -146,12 +144,10 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 应用界面设置 * 应用界面设置
* *
* * @date 2014-12-21-下午6:32:43
* @date 2014-12-21-下午6:32:43 */
*
*/
public void updateUI() { public void updateUI() {
GridUIProcessor localGridUIProcessor = ExtraDesignClassManager.getInstance().getSingle(GridUIProcessor.MARK_STRING, new DefaultGridUIProcessor()); GridUIProcessor localGridUIProcessor = ExtraDesignClassManager.getInstance().getSingle(GridUIProcessor.MARK_STRING, new DefaultGridUIProcessor());
ComponentUI localComponentUI = localGridUIProcessor.appearanceForGrid(this.resolution); ComponentUI localComponentUI = localGridUIProcessor.appearanceForGrid(this.resolution);
@ -160,14 +156,11 @@ public class Grid extends BaseGridComponent {
/** /**
* 是否显示格子线 * 是否显示格子线
* *
* @return 是否显示格子线 * @return 是否显示格子线
* * @date 2014-12-21-下午6:32:13
* */
* @date 2014-12-21-下午6:32:13
*
*/
public boolean isShowGridLine() { public boolean isShowGridLine() {
return showGridLine; return showGridLine;
} }
@ -183,7 +176,7 @@ public class Grid extends BaseGridComponent {
this.getElementCasePane().repaint(); this.getElementCasePane().repaint();
} }
public GridMouseAdapter getGridMouseAdapter(){ public GridMouseAdapter getGridMouseAdapter() {
return this.gridMouseAdapter; return this.gridMouseAdapter;
} }
@ -210,14 +203,11 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 是否显示分页线 * 是否显示分页线
* *
* @return 是否显示分页线 * @return 是否显示分页线
* * @date 2014-12-21-下午6:31:45
* */
* @date 2014-12-21-下午6:31:45
*
*/
public boolean isShowPaginateLine() { public boolean isShowPaginateLine() {
return isShowPaginateLine; return isShowPaginateLine;
} }
@ -253,14 +243,11 @@ public class Grid extends BaseGridComponent {
/** /**
* 是否显示垂直冻结线 * 是否显示垂直冻结线
* *
* @return 是否显示垂直冻结线 * @return 是否显示垂直冻结线
* * @date 2014-12-21-下午6:29:35
* */
* @date 2014-12-21-下午6:29:35
*
*/
public boolean isShowVerticalFrozenLine() { public boolean isShowVerticalFrozenLine() {
return isShowVerticalFrozenLine; return isShowVerticalFrozenLine;
} }
@ -295,14 +282,11 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 是否显示水平冻结线 * 是否显示水平冻结线
* *
* @return 是否显示水平冻结线 * @return 是否显示水平冻结线
* * @date 2014-12-21-下午6:29:35
* */
* @date 2014-12-21-下午6:29:35
*
*/
public boolean isShowHorizontalFrozenLine() { public boolean isShowHorizontalFrozenLine() {
return isShowHorizontalFrozenLine; return isShowHorizontalFrozenLine;
} }
@ -377,14 +361,11 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 组件是否可以被编辑 * 组件是否可以被编辑
* *
* @return 组件是否可以被编辑 * @return 组件是否可以被编辑
* * @date 2014-12-21-下午6:29:09
* */
* @date 2014-12-21-下午6:29:09
*
*/
public boolean isEditable() { public boolean isEditable() {
return editable; return editable;
} }
@ -501,27 +482,21 @@ public class Grid extends BaseGridComponent {
// /////////////editor begin // /////////////editor begin
/** /**
* 是否处于编辑状态 * 是否处于编辑状态
* *
* @return 是否处于编辑状态 * @return 是否处于编辑状态
* * @date 2014-12-21-下午6:28:45
* */
* @date 2014-12-21-下午6:28:45
*
*/
public boolean isEditing() { public boolean isEditing() {
return this.editorComponent != null; return this.editorComponent != null;
} }
/** /**
* 当前编辑对象是否为单元格 * 当前编辑对象是否为单元格
* *
* @return 当前编辑对象是否为单元格 * @return 当前编辑对象是否为单元格
* * @date 2014-12-21-下午6:28:18
* */
* @date 2014-12-21-下午6:28:18
*
*/
public boolean isCellEditing() { public boolean isCellEditing() {
return this.isEditing() && cellEditor != null && notShowingTableSelectPane; return this.isEditing() && cellEditor != null && notShowingTableSelectPane;
} }
@ -534,27 +509,21 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 是否处于智能选择单元格阶段 * 是否处于智能选择单元格阶段
* *
* @return 是否处于智能选择单元格阶段 * @return 是否处于智能选择单元格阶段
* * @date 2014-12-21-下午6:27:36
* */
* @date 2014-12-21-下午6:27:36
*
*/
public boolean IsNotShowingTableSelectPane() { public boolean IsNotShowingTableSelectPane() {
return this.notShowingTableSelectPane; return this.notShowingTableSelectPane;
} }
/** /**
* 当前是否在编辑悬浮元素 * 当前是否在编辑悬浮元素
* *
* @return 是否在编辑悬浮元素 * @return 是否在编辑悬浮元素
* * @date 2014-12-21-下午6:26:46
* */
* @date 2014-12-21-下午6:26:46
*
*/
public boolean isFloatEditing() { public boolean isFloatEditing() {
return this.isEditing() && floatEditor != null; return this.isEditing() && floatEditor != null;
} }
@ -566,7 +535,7 @@ public class Grid extends BaseGridComponent {
* @param column the column of the cell to edit, where 0 is the first column; * @param column the column of the cell to edit, where 0 is the first column;
* @param row the row of the cell to edit, where 0 is the first row * @param row the row of the cell to edit, where 0 is the first row
* @return the editor for this cell; if <code>null</code> return the default * @return the editor for this cell; if <code>null</code> return the default
* editor for this type of cell * editor for this type of cell
* @see com.fr.design.cell.editor.CellEditor * @see com.fr.design.cell.editor.CellEditor
*/ */
public CellEditor getCellEditor(int column, int row) { public CellEditor getCellEditor(int column, int row) {
@ -598,7 +567,7 @@ public class Grid extends BaseGridComponent {
* edited. If nothing is being edited, returns -1. * edited. If nothing is being edited, returns -1.
* *
* @return the index of the column that contains the cell currently being * @return the index of the column that contains the cell currently being
* edited; returns -1 if nothing being edited * edited; returns -1 if nothing being edited
*/ */
public int getEditingColumn() { public int getEditingColumn() {
return editingColumn; return editingColumn;
@ -618,7 +587,7 @@ public class Grid extends BaseGridComponent {
* If nothing is being edited, returns -1. * If nothing is being edited, returns -1.
* *
* @return the index of the row that contains the cell currently being * @return the index of the row that contains the cell currently being
* edited; returns -1 if nothing being edited * edited; returns -1 if nothing being edited
*/ */
public int getEditingRow() { public int getEditingRow() {
return editingRow; return editingRow;
@ -800,25 +769,20 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 开始单元格编辑 * 开始单元格编辑
* *
* * @date 2014-12-21-下午6:25:17
* @date 2014-12-21-下午6:25:17 */
*
*/
public void startEditing() { public void startEditing() {
this.startEditing(false); this.startEditing(false);
} }
/** /**
* 开始单元格编辑 * 开始单元格编辑
* *
* @param byKeyEvent 是否为键盘触发 * @param byKeyEvent 是否为键盘触发
* * @date 2014-12-21-下午6:25:17
* */
* @date 2014-12-21-下午6:25:17
*
*/
protected void startEditing(boolean byKeyEvent) { protected void startEditing(boolean byKeyEvent) {
ElementCasePane reportPane = this.getElementCasePane(); ElementCasePane reportPane = this.getElementCasePane();
ElementCase report = reportPane.getEditingElementCase(); ElementCase report = reportPane.getEditingElementCase();
@ -867,19 +831,15 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 开始单元格编辑 * 开始单元格编辑
* *
* @param column * @param column
* @param row * @param row
* @param cellTypeClass 单元格类型 * @param cellTypeClass 单元格类型
* @param byKeyEvent 是否为键盘触发 * @param byKeyEvent 是否为键盘触发
* * @return 编辑是否成功
* @return 编辑是否成功 * @date 2014-12-21-下午6:25:17
* */
*
* @date 2014-12-21-下午6:25:17
*
*/
public boolean startCellEditingAt_DEC(int column, int row, Class cellTypeClass, boolean byKeyEvent) { public boolean startCellEditingAt_DEC(int column, int row, Class cellTypeClass, boolean byKeyEvent) {
if (this.isEditing()) { if (this.isEditing()) {
this.stopEditing();// 需要先停止正在进行的编辑. this.stopEditing();// 需要先停止正在进行的编辑.
@ -954,12 +914,10 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 停止编辑状态 * 停止编辑状态
* *
* * @date 2014-12-21-下午6:24:54
* @date 2014-12-21-下午6:24:54 */
*
*/
public void stopEditing() { public void stopEditing() {
// 首先判断是哪种类型的编辑. // 首先判断是哪种类型的编辑.
if (this.isCellEditing()) { if (this.isCellEditing()) {
@ -1117,10 +1075,10 @@ public class Grid extends BaseGridComponent {
if (styleChange || imageChange) { if (styleChange || imageChange) {
return true; return true;
} }
} else { } else {
if(newValue instanceof RichText){ if (newValue instanceof RichText) {
setShowAsHtml(this.editingCellElement); setShowAsHtml(this.editingCellElement);
} }
Object oldValue = this.editingCellElement.getValue(); Object oldValue = this.editingCellElement.getValue();
if (!ComparatorUtils.equals_exactly(oldValue, newValue)) { if (!ComparatorUtils.equals_exactly(oldValue, newValue)) {
@ -1131,15 +1089,15 @@ public class Grid extends BaseGridComponent {
return false; return false;
} }
private void setShowAsHtml(CellElement cellElement){ private void setShowAsHtml(CellElement cellElement) {
CellGUIAttr guiAttr = cellElement.getCellGUIAttr(); CellGUIAttr guiAttr = cellElement.getCellGUIAttr();
if(guiAttr == null){ if (guiAttr == null) {
guiAttr = new CellGUIAttr(); guiAttr = new CellGUIAttr();
cellElement.setCellGUIAttr(guiAttr); cellElement.setCellGUIAttr(guiAttr);
} }
guiAttr.setShowAsHTML(true); guiAttr.setShowAsHTML(true);
} }
/** /**
* 当单元格里的内容过长时自动调整单元格 * 当单元格里的内容过长时自动调整单元格
@ -1148,34 +1106,32 @@ public class Grid extends BaseGridComponent {
*/ */
private void shrinkToFit(TemplateElementCase tplEC) { private void shrinkToFit(TemplateElementCase tplEC) {
if (editingCellElement == null) { if (editingCellElement == null) {
return; return;
} }
Object editElementValue = editingCellElement.getValue(); Object editElementValue = editingCellElement.getValue();
if (valueNeedFit(editElementValue)) { if (valueNeedFit(editElementValue)) {
int mode = this.getElementCasePane().getReportSettings().getShrinkToFitMode(); int mode = this.getElementCasePane().getReportSettings().getShrinkToFitMode();
GridUtils.shrinkToFit(mode, tplEC, editingCellElement); GridUtils.shrinkToFit(mode, tplEC, editingCellElement);
} }
} }
//是否需要根据内容自动调整, 目前只有字符串, 数字, 富文本需要 //是否需要根据内容自动调整, 目前只有字符串, 数字, 富文本需要
private boolean valueNeedFit(Object value){ private boolean valueNeedFit(Object value) {
if(value == null){ if (value == null) {
return false; return false;
} }
return value instanceof String || return value instanceof String ||
value instanceof Number || value instanceof Number ||
value instanceof RichText; value instanceof RichText;
} }
/** /**
* 取消编辑状态 * 取消编辑状态
* *
* * @date 2014-12-21-下午6:24:34
* @date 2014-12-21-下午6:24:34 */
*
*/
public void cancelEditing() { public void cancelEditing() {
if (this.isEditing()) { if (this.isEditing()) {
removeEditor(); removeEditor();
@ -1184,12 +1140,10 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 移除选中组件 * 移除选中组件
* *
* * @date 2014-12-21-下午6:24:16
* @date 2014-12-21-下午6:24:16 */
*
*/
public void removeEditor() { public void removeEditor() {
if (this.isCellEditing()) { if (this.isCellEditing()) {
this.removeCellEditor(); this.removeCellEditor();
@ -1199,12 +1153,10 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 移除单元格组件 * 移除单元格组件
* *
* * @date 2014-12-21-下午6:24:00
* @date 2014-12-21-下午6:24:00 */
*
*/
public void removeCellEditor() { public void removeCellEditor() {
CellEditor cellEditor = getCellEditor(); CellEditor cellEditor = getCellEditor();
if (cellEditor == null) { if (cellEditor == null) {
@ -1233,12 +1185,10 @@ public class Grid extends BaseGridComponent {
} }
/** /**
* 移除悬浮元素组件 * 移除悬浮元素组件
* *
* * @date 2014-12-21-下午6:23:38
* @date 2014-12-21-下午6:23:38 */
*
*/
public void removeFloatEditor() { public void removeFloatEditor() {
FloatEditor floatEditor = getFloatEditor(); FloatEditor floatEditor = getFloatEditor();
if (floatEditor != null) { if (floatEditor != null) {
@ -1290,31 +1240,24 @@ public class Grid extends BaseGridComponent {
// /////////////editor end // /////////////editor end
/** /**
* 鼠标点击事件 * 鼠标点击事件
* *
* @param evtX x坐标 * @param evtX x坐标
* @param evtY y坐标 * @param evtY y坐标
* * @date 2014-12-21-下午6:22:56
* */
* @date 2014-12-21-下午6:22:56
*
*/
public void doMousePress(double evtX, double evtY) { public void doMousePress(double evtX, double evtY) {
dispatchEvent(new MouseEvent(this, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, (int) evtX, (int) evtY, 1, false)); dispatchEvent(new MouseEvent(this, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, (int) evtX, (int) evtY, 1, false));
} }
/** /**
* 计算oldRectangle,因为CellElement的合并会变成多大的区域. * 计算oldRectangle,因为CellElement的合并会变成多大的区域.
* *
* @param report 当前格子报表 * @param report 当前格子报表
* @param oldRectangle 之前的选中区域 * @param oldRectangle 之前的选中区域
* * @return 插入的区域
* @return 插入的区域 * @date 2014-12-21-下午6:22:21
* */
*
* @date 2014-12-21-下午6:22:21
*
*/
public Rectangle caculateIntersectsUnion(ElementCase report, Rectangle oldRectangle) { public Rectangle caculateIntersectsUnion(ElementCase report, Rectangle oldRectangle) {
Rectangle newRectangle = new Rectangle(oldRectangle); Rectangle newRectangle = new Rectangle(oldRectangle);

4
designer/src/com/fr/grid/GridHeader.java

@ -1,5 +1,7 @@
package com.fr.grid; package com.fr.grid;
import com.fr.design.constants.UIConstants;
import java.awt.*; import java.awt.*;
@ -7,7 +9,7 @@ public abstract class GridHeader<T> extends BaseGridComponent {
public final static int SIZE_ADJUST = 4; public final static int SIZE_ADJUST = 4;
//属性 //属性
private Color separatorLineColor = new Color(172, 168, 153); //separator lines private Color separatorLineColor = UIConstants.RULER_LINE_COLOR; //separator lines
private Color selectedForeground = Color.black; private Color selectedForeground = Color.black;
private Color selectedBackground = new Color(208, 240, 252); private Color selectedBackground = new Color(208, 240, 252);

Loading…
Cancel
Save