diff --git a/designer/src/com/fr/design/actions/insert/flot/ChartFloatAction.java b/designer/src/com/fr/design/actions/insert/flot/ChartFloatAction.java index ce05628da4..292d4f2876 100644 --- a/designer/src/com/fr/design/actions/insert/flot/ChartFloatAction.java +++ b/designer/src/com/fr/design/actions/insert/flot/ChartFloatAction.java @@ -4,6 +4,7 @@ package com.fr.design.actions.insert.flot; import com.fr.base.BaseUtils; +import com.fr.base.DynamicUnitList; import com.fr.base.Style; import com.fr.base.chart.BaseChartCollection; import com.fr.design.actions.ElementCaseAction; @@ -16,10 +17,14 @@ import com.fr.design.menu.MenuKeySet; import com.fr.design.module.DesignModuleFactory; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.grid.Grid; import com.fr.grid.selection.FloatSelection; +import com.fr.report.ReportHelper; import com.fr.report.cell.FloatElement; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.Constants; import com.fr.stable.bridge.StableFactory; +import com.fr.stable.unit.FU; import com.fr.stable.unit.OLDPIX; import javax.swing.*; @@ -85,11 +90,31 @@ public class ChartFloatAction extends ElementCaseAction { FloatElement newFloatElement; try { newFloatElement = new FloatElement(chartDialog.getChartCollection().clone()); - newFloatElement.setLeftDistance(new OLDPIX(20)); - newFloatElement.setTopDistance(new OLDPIX(20)); newFloatElement.setWidth(new OLDPIX(BaseChartCollection.CHART_DEFAULT_WIDTH)); newFloatElement.setHeight(new OLDPIX(BaseChartCollection.CHART_DEFAULT_HEIGHT)); + Grid grid = reportPane.getGrid(); + TemplateElementCase report = reportPane.getEditingElementCase(); + DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); + DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); + int horizentalScrollValue = grid.getHorizontalValue(); + int verticalScrollValue = grid.getVerticalValue(); + + int resolution = grid.getResolution(); + int floatWdith = newFloatElement.getWidth().toPixI(resolution); + int floatHeight = newFloatElement.getWidth().toPixI(resolution); + + int leftDifference = (grid.getWidth() - floatWdith) > 0 ? (grid.getWidth() - floatWdith) : 0; + int topDifference = (grid.getHeight() - floatHeight) > 0 ? (grid.getHeight() - floatHeight) : 0; + FU evtX_fu = FU.valueOfPix((leftDifference) / 2, resolution); + FU evtY_fu = FU.valueOfPix((topDifference) / 2, resolution); + + 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)); diff --git a/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java b/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java index 78b408347f..9861499bf9 100644 --- a/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java +++ b/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java @@ -4,6 +4,7 @@ package com.fr.design.actions.insert.flot; import com.fr.base.BaseUtils; +import com.fr.base.DynamicUnitList; import com.fr.base.ScreenResolution; import com.fr.design.actions.ElementCaseAction; import com.fr.design.dialog.BasicDialog; @@ -14,9 +15,12 @@ import com.fr.design.mainframe.ElementCasePane; import com.fr.design.menu.MenuKeySet; import com.fr.design.report.SelectImagePane; import com.fr.general.Inter; +import com.fr.grid.Grid; import com.fr.grid.selection.FloatSelection; +import com.fr.report.ReportHelper; import com.fr.report.cell.FloatElement; import com.fr.report.cell.cellattr.CellImage; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.CoreGraphHelper; import com.fr.stable.unit.FU; @@ -87,12 +91,33 @@ public class ImageFloatAction extends ElementCaseAction { CoreGraphHelper.waitForImage(image); floatElement.setValue(image); - - int resolution = ScreenResolution.getScreenResolution(); + Grid grid = reportPane.getGrid(); + int resolution = grid.getResolution(); floatElement.setWidth(FU.valueOfPix(image.getWidth(null), resolution)); floatElement.setHeight(FU.valueOfPix(image.getHeight(null), resolution)); + TemplateElementCase report = reportPane.getEditingElementCase(); + DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); + DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); + int horizentalScrollValue = grid.getHorizontalValue(); + int verticalScrollValue = grid.getVerticalValue(); + + int floatWdith = floatElement.getWidth().toPixI(resolution); + int floatHeight = floatElement.getHeight().toPixI(resolution); + + int leftDifference = (grid.getWidth() - floatWdith) > 0 ? (grid.getWidth() - floatWdith) : 0; + int topDifference = (grid.getHeight() - floatHeight) > 0 ? (grid.getHeight() - floatHeight) : 0; + FU evtX_fu = FU.valueOfPix((leftDifference) / 2, resolution); + FU evtY_fu = FU.valueOfPix((topDifference) / 2, resolution); + + FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); + FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); + + floatElement.setLeftDistance(leftDistance); + floatElement.setTopDistance(topDistance); + floatElement.setStyle(cellImage.getStyle()); - reportPane.addFloatElementToCenterOfElementPane(floatElement); +// reportPane.addFloatElementToCenterOfElementPane(floatElement); + reportPane.getEditingElementCase().addFloatElement(floatElement); reportPane.setSelection(new FloatSelection(floatElement.getName())); returnValue = true; diff --git a/designer_base/src/com/fr/design/images/buttonicon/type_bool.png b/designer_base/src/com/fr/design/images/buttonicon/type_bool.png index 7b0dfd3af6..e20938ff16 100644 Binary files a/designer_base/src/com/fr/design/images/buttonicon/type_bool.png and b/designer_base/src/com/fr/design/images/buttonicon/type_bool.png differ diff --git a/designer_base/src/com/fr/design/images/buttonicon/type_date.png b/designer_base/src/com/fr/design/images/buttonicon/type_date.png index c38c9d3dde..3a0ad5c747 100644 Binary files a/designer_base/src/com/fr/design/images/buttonicon/type_date.png and b/designer_base/src/com/fr/design/images/buttonicon/type_date.png differ diff --git a/designer_base/src/com/fr/design/images/buttonicon/type_double.png b/designer_base/src/com/fr/design/images/buttonicon/type_double.png index 4cdd73fb4f..1701ff8d6c 100644 Binary files a/designer_base/src/com/fr/design/images/buttonicon/type_double.png and b/designer_base/src/com/fr/design/images/buttonicon/type_double.png differ diff --git a/designer_base/src/com/fr/design/images/buttonicon/type_formula.png b/designer_base/src/com/fr/design/images/buttonicon/type_formula.png index cffd7e4613..278ddc985a 100644 Binary files a/designer_base/src/com/fr/design/images/buttonicon/type_formula.png and b/designer_base/src/com/fr/design/images/buttonicon/type_formula.png differ diff --git a/designer_base/src/com/fr/design/images/buttonicon/type_int.png b/designer_base/src/com/fr/design/images/buttonicon/type_int.png index e15d387de0..5818edbe7d 100644 Binary files a/designer_base/src/com/fr/design/images/buttonicon/type_int.png and b/designer_base/src/com/fr/design/images/buttonicon/type_int.png differ diff --git a/designer_base/src/com/fr/design/images/buttonicon/type_string.png b/designer_base/src/com/fr/design/images/buttonicon/type_string.png index 0101426ea2..b9aafab2d0 100644 Binary files a/designer_base/src/com/fr/design/images/buttonicon/type_string.png and b/designer_base/src/com/fr/design/images/buttonicon/type_string.png differ