|
|
@ -7,7 +7,6 @@ import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.DynamicUnitList; |
|
|
|
import com.fr.base.DynamicUnitList; |
|
|
|
import com.fr.base.Style; |
|
|
|
import com.fr.base.Style; |
|
|
|
import com.fr.base.chart.BaseChartCollection; |
|
|
|
import com.fr.base.chart.BaseChartCollection; |
|
|
|
import com.fr.chart.chartattr.ChartCollection; |
|
|
|
|
|
|
|
import com.fr.design.actions.ElementCaseAction; |
|
|
|
import com.fr.design.actions.ElementCaseAction; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
@ -18,8 +17,6 @@ import com.fr.design.menu.MenuKeySet; |
|
|
|
import com.fr.design.module.DesignModuleFactory; |
|
|
|
import com.fr.design.module.DesignModuleFactory; |
|
|
|
import com.fr.grid.Grid; |
|
|
|
import com.fr.grid.Grid; |
|
|
|
import com.fr.grid.selection.FloatSelection; |
|
|
|
import com.fr.grid.selection.FloatSelection; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
import com.fr.plugin.chart.vanchart.VanChart; |
|
|
|
|
|
|
|
import com.fr.report.ReportHelper; |
|
|
|
import com.fr.report.ReportHelper; |
|
|
|
import com.fr.report.cell.FloatElement; |
|
|
|
import com.fr.report.cell.FloatElement; |
|
|
|
import com.fr.report.elementcase.TemplateElementCase; |
|
|
|
import com.fr.report.elementcase.TemplateElementCase; |
|
|
@ -88,51 +85,39 @@ public class ChartFloatAction extends ElementCaseAction { |
|
|
|
public void doOk() { |
|
|
|
public void doOk() { |
|
|
|
isRecordNeeded = true; |
|
|
|
isRecordNeeded = true; |
|
|
|
FloatElement newFloatElement; |
|
|
|
FloatElement newFloatElement; |
|
|
|
try { |
|
|
|
newFloatElement = new FloatElement(chartDialog.getChartCollection()); |
|
|
|
//TODO @Bjorn 这里不知道为什么要把ChartCollection克隆一下,会导致chart的ID发生变化,影响记录埋点的功能。
|
|
|
|
newFloatElement.setWidth(new OLDPIX(BaseChartCollection.CHART_DEFAULT_WIDTH)); |
|
|
|
//TODO 不知道去掉clone之后会有什么影响,下个版本的迭代中优化试着去掉clone方法,测试看看会不会有问题。
|
|
|
|
newFloatElement.setHeight(new OLDPIX(BaseChartCollection.CHART_DEFAULT_HEIGHT)); |
|
|
|
ChartCollection chartCollection = (ChartCollection) chartDialog.getChartCollection().clone(); |
|
|
|
|
|
|
|
VanChart vanChart = ((ChartCollection) chartDialog.getChartCollection()).getSelectedChartProvider(VanChart.class); |
|
|
|
Grid grid = reportPane.getGrid(); |
|
|
|
if (vanChart != null) { |
|
|
|
TemplateElementCase report = reportPane.getEditingElementCase(); |
|
|
|
chartCollection.getSelectedChartProvider(VanChart.class).setUuid(vanChart.getUuid()); |
|
|
|
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); |
|
|
|
} |
|
|
|
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); |
|
|
|
newFloatElement = new FloatElement(chartCollection); |
|
|
|
int horizentalScrollValue = grid.getHorizontalValue(); |
|
|
|
|
|
|
|
int verticalScrollValue = grid.getVerticalValue(); |
|
|
|
newFloatElement.setWidth(new OLDPIX(BaseChartCollection.CHART_DEFAULT_WIDTH)); |
|
|
|
|
|
|
|
newFloatElement.setHeight(new OLDPIX(BaseChartCollection.CHART_DEFAULT_HEIGHT)); |
|
|
|
int resolution = grid.getResolution(); |
|
|
|
|
|
|
|
int floatWdith = newFloatElement.getWidth().toPixI(resolution); |
|
|
|
Grid grid = reportPane.getGrid(); |
|
|
|
int floatHeight = newFloatElement.getWidth().toPixI(resolution); |
|
|
|
TemplateElementCase report = reportPane.getEditingElementCase(); |
|
|
|
|
|
|
|
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); |
|
|
|
int leftDifference = (grid.getWidth() - floatWdith) > 0 ? (grid.getWidth() - floatWdith) : 0; |
|
|
|
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); |
|
|
|
int topDifference = (grid.getHeight() - floatHeight) > 0 ? (grid.getHeight() - floatHeight) : 0; |
|
|
|
int horizentalScrollValue = grid.getHorizontalValue(); |
|
|
|
FU evtX_fu = FU.valueOfPix((leftDifference) / 2, resolution); |
|
|
|
int verticalScrollValue = grid.getVerticalValue(); |
|
|
|
FU evtY_fu = FU.valueOfPix((topDifference) / 2, resolution); |
|
|
|
|
|
|
|
|
|
|
|
int resolution = grid.getResolution(); |
|
|
|
FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); |
|
|
|
int floatWdith = newFloatElement.getWidth().toPixI(resolution); |
|
|
|
FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); |
|
|
|
int floatHeight = newFloatElement.getWidth().toPixI(resolution); |
|
|
|
|
|
|
|
|
|
|
|
newFloatElement.setLeftDistance(leftDistance); |
|
|
|
int leftDifference = (grid.getWidth() - floatWdith) > 0 ? (grid.getWidth() - floatWdith) : 0; |
|
|
|
newFloatElement.setTopDistance(topDistance); |
|
|
|
int topDifference = (grid.getHeight() - floatHeight) > 0 ? (grid.getHeight() - floatHeight) : 0; |
|
|
|
|
|
|
|
FU evtX_fu = FU.valueOfPix((leftDifference) / 2, resolution); |
|
|
|
Style style = newFloatElement.getStyle(); |
|
|
|
FU evtY_fu = FU.valueOfPix((topDifference) / 2, resolution); |
|
|
|
if (style != null) { |
|
|
|
|
|
|
|
newFloatElement.setStyle(style.deriveBorder(Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black)); |
|
|
|
FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); |
|
|
|
|
|
|
|
FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newFloatElement.setLeftDistance(leftDistance); |
|
|
|
|
|
|
|
newFloatElement.setTopDistance(topDistance); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Style style = newFloatElement.getStyle(); |
|
|
|
|
|
|
|
if (style != null) { |
|
|
|
|
|
|
|
newFloatElement.setStyle(style.deriveBorder(Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
reportPane.getEditingElementCase().addFloatElement(newFloatElement); |
|
|
|
|
|
|
|
reportPane.setSelection(new FloatSelection(newFloatElement.getName())); |
|
|
|
|
|
|
|
reportPane.fireSelectionChangeListener(); |
|
|
|
|
|
|
|
} catch (CloneNotSupportedException e) { |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error("Error in Float"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
reportPane.getEditingElementCase().addFloatElement(newFloatElement); |
|
|
|
|
|
|
|
reportPane.setSelection(new FloatSelection(newFloatElement.getName())); |
|
|
|
|
|
|
|
reportPane.fireSelectionChangeListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|