|
|
@ -10,6 +10,7 @@ import java.awt.Graphics2D; |
|
|
|
import java.awt.Point; |
|
|
|
import java.awt.Point; |
|
|
|
import java.awt.Rectangle; |
|
|
|
import java.awt.Rectangle; |
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
|
@ -27,12 +28,14 @@ import com.fr.general.Inter; |
|
|
|
import com.fr.page.PaperSettingProvider; |
|
|
|
import com.fr.page.PaperSettingProvider; |
|
|
|
import com.fr.page.ReportSettingsProvider; |
|
|
|
import com.fr.page.ReportSettingsProvider; |
|
|
|
import com.fr.poly.creator.BlockCreator; |
|
|
|
import com.fr.poly.creator.BlockCreator; |
|
|
|
|
|
|
|
import com.fr.poly.creator.ECBlockCreator; |
|
|
|
import com.fr.poly.model.AddedData; |
|
|
|
import com.fr.poly.model.AddedData; |
|
|
|
import com.fr.poly.model.AddingData; |
|
|
|
import com.fr.poly.model.AddingData; |
|
|
|
import com.fr.report.report.Report; |
|
|
|
import com.fr.report.report.Report; |
|
|
|
import com.fr.report.report.TemplateReport; |
|
|
|
import com.fr.report.report.TemplateReport; |
|
|
|
import com.fr.report.stable.ReportConstants; |
|
|
|
import com.fr.report.stable.ReportConstants; |
|
|
|
import com.fr.stable.Constants; |
|
|
|
import com.fr.stable.Constants; |
|
|
|
|
|
|
|
import com.fr.stable.CoreGraphHelper; |
|
|
|
import com.fr.stable.unit.UNIT; |
|
|
|
import com.fr.stable.unit.UNIT; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -44,13 +47,19 @@ public class PolyDesignUI extends ComponentUI { |
|
|
|
|
|
|
|
|
|
|
|
private static final double SCROLL_POINT = 50; |
|
|
|
private static final double SCROLL_POINT = 50; |
|
|
|
private static final int SCROLL_DISTANCE = 15; |
|
|
|
private static final int SCROLL_DISTANCE = 15; |
|
|
|
|
|
|
|
private static final int CREATORWIDTH = 30; |
|
|
|
|
|
|
|
private static final int CREATORGEIGHT = 19; |
|
|
|
|
|
|
|
private static final int TEN = 10; |
|
|
|
|
|
|
|
private static final int HHUNDRED = 100; |
|
|
|
private PolyDesigner designer; |
|
|
|
private PolyDesigner designer; |
|
|
|
private int resolution = ScreenResolution.getScreenResolution(); |
|
|
|
private int resolution; |
|
|
|
private int ten = 10; |
|
|
|
private float time; |
|
|
|
private int hundred = 100; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PolyDesignUI() { |
|
|
|
public PolyDesignUI(int resolution) { |
|
|
|
|
|
|
|
if (resolution == 0){ |
|
|
|
|
|
|
|
resolution = ScreenResolution.getScreenResolution(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.resolution = resolution; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -83,6 +92,8 @@ public class PolyDesignUI extends ComponentUI { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void paint(Graphics g, JComponent c) { |
|
|
|
public void paint(Graphics g, JComponent c) { |
|
|
|
|
|
|
|
this.resolution = ((PolyArea)c).getResolution(); |
|
|
|
|
|
|
|
this.time = (float)resolution/ScreenResolution.getScreenResolution(); |
|
|
|
paintBackground(g, c); |
|
|
|
paintBackground(g, c); |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
paintAddedData(g2d); |
|
|
|
paintAddedData(g2d); |
|
|
@ -100,20 +111,27 @@ public class PolyDesignUI extends ComponentUI { |
|
|
|
BlockCreator creator = addedData.getAddedAt(i); |
|
|
|
BlockCreator creator = addedData.getAddedAt(i); |
|
|
|
// richer:如果当前这个组件正在编辑,那么他是完全被他的编辑器所遮挡的,不需要画出来
|
|
|
|
// richer:如果当前这个组件正在编辑,那么他是完全被他的编辑器所遮挡的,不需要画出来
|
|
|
|
if (creator == designer.getSelection()) { |
|
|
|
if (creator == designer.getSelection()) { |
|
|
|
paintPositionLine(g, creator.getX(), creator.getY(), designer.getHorizontalValue(), designer |
|
|
|
if (creator instanceof ECBlockCreator){ |
|
|
|
.getVerticalValue()); |
|
|
|
int x = (int) ((creator.getX()-CREATORWIDTH)*time)+CREATORWIDTH; |
|
|
|
if (creator.getEditor().isDragging()) { |
|
|
|
int y = (int) ((creator.getY()-CREATORGEIGHT)*time)+CREATORGEIGHT; |
|
|
|
creator.getEditor().paintAbsorptionline(g); |
|
|
|
paintPositionLine(g, x, y, (int) (designer.getHorizontalValue()*time), (int) (designer.getVerticalValue()*time)); |
|
|
|
//如果与其他块重合了, 需要画出提示禁止重叠
|
|
|
|
}else { |
|
|
|
changeForbiddenWindowVisibility(creator); |
|
|
|
int x = (int) (creator.getX()*time); |
|
|
|
//到边缘地带自动滚动
|
|
|
|
int y = (int) (creator.getY()*time); |
|
|
|
scrollWhenCreatorAtCorner(creator); |
|
|
|
paintPositionLine(g, x, y, (int) (designer.getHorizontalValue()*time), (int) (designer.getVerticalValue()*time)); |
|
|
|
}else{ |
|
|
|
} |
|
|
|
creator.getEditor().hideForbiddenWindow(); |
|
|
|
if (creator.getEditor().isDragging()) { |
|
|
|
} |
|
|
|
creator.getEditor().paintAbsorptionline(g); |
|
|
|
|
|
|
|
//如果与其他块重合了, 需要画出提示禁止重叠
|
|
|
|
|
|
|
|
changeForbiddenWindowVisibility(creator); |
|
|
|
|
|
|
|
//到边缘地带自动滚动
|
|
|
|
|
|
|
|
scrollWhenCreatorAtCorner(creator); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
creator.getEditor().hideForbiddenWindow(); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
paintCreator(g, creator, creator.getX() - designer.getHorizontalValue(), creator.getY() - designer.getVerticalValue(), |
|
|
|
paintCreator(g, creator, (int) (creator.getX()*time - designer.getHorizontalValue()*time), (int) (creator.getY()*time - designer.getVerticalValue()*time), |
|
|
|
creator.getWidth(), creator.getHeight()); |
|
|
|
(int) (creator.getWidth()*time), (int) (creator.getHeight()*time)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -126,8 +144,8 @@ public class PolyDesignUI extends ComponentUI { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int x = (int) (designer.getAreaLocationX() + pixRec.getCenterX() - designer.getHorizontalValue()); |
|
|
|
int x = (int) (designer.getAreaLocationX() + pixRec.getCenterX()*time - designer.getHorizontalValue()); |
|
|
|
int y = (int) (designer.getAreaLocationY() + pixRec.getCenterY() - designer.getVerticalValue()); |
|
|
|
int y = (int) (designer.getAreaLocationY() + pixRec.getCenterY()*time - designer.getVerticalValue()); |
|
|
|
creator.getEditor().showForbiddenWindow(x, y); |
|
|
|
creator.getEditor().showForbiddenWindow(x, y); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -183,16 +201,16 @@ public class PolyDesignUI extends ComponentUI { |
|
|
|
|
|
|
|
|
|
|
|
private String convertUnit(int i) { |
|
|
|
private String convertUnit(int i) { |
|
|
|
short unit = designer.getRulerLengthUnit(); |
|
|
|
short unit = designer.getRulerLengthUnit(); |
|
|
|
int resolution = ScreenResolution.getScreenResolution(); |
|
|
|
// int resolution = ScreenResolution.getScreenResolution();
|
|
|
|
if (unit == Constants.UNIT_MM) { |
|
|
|
if (unit == Constants.UNIT_MM) { |
|
|
|
Double j = (i + 2) * 1.0 * Constants.HUNDRED_FU_PER_INCH / Constants.HUNDRED_FU_PER_MM / resolution; |
|
|
|
Double j = (i + 2) * 1.0 * Constants.HUNDRED_FU_PER_INCH / Constants.HUNDRED_FU_PER_MM / resolution; |
|
|
|
return j.intValue() + Inter.getLocText("Unit_MM"); |
|
|
|
return j.intValue() + Inter.getLocText("Unit_MM"); |
|
|
|
} else if (unit == Constants.UNIT_CM) { |
|
|
|
} else if (unit == Constants.UNIT_CM) { |
|
|
|
Double j = (i + 2) * 1.0 * Constants.HUNDRED_FU_PER_INCH / Constants.HUNDRED_FU_PER_MM / resolution; |
|
|
|
Double j = (i + 2) * 1.0 * Constants.HUNDRED_FU_PER_INCH / Constants.HUNDRED_FU_PER_MM / resolution; |
|
|
|
return new DecimalFormat("0.0").format(j.intValue() * 1.0 / ten) + Inter.getLocText("Unit_CM"); |
|
|
|
return new DecimalFormat("0.0").format(j.intValue() * 1.0 / TEN) + Inter.getLocText("Unit_CM"); |
|
|
|
} else if (unit == Constants.UNIT_INCH) { |
|
|
|
} else if (unit == Constants.UNIT_INCH) { |
|
|
|
Double j = i == 0 ? 0 : (i + 2) * 1.0 / resolution * hundred; |
|
|
|
Double j = i == 0 ? 0 : (i + 2) * 1.0 / resolution * HHUNDRED; |
|
|
|
return new DecimalFormat("0.00").format(j.intValue() * 1.0 / hundred) + Inter.getLocText("Unit_INCH"); |
|
|
|
return new DecimalFormat("0.00").format(j.intValue() * 1.0 / HHUNDRED) + Inter.getLocText("Unit_INCH"); |
|
|
|
} else if (unit == Constants.UNIT_PT) { |
|
|
|
} else if (unit == Constants.UNIT_PT) { |
|
|
|
int j = i == 0 ? 0 : (i + 2) * UNIT.PT_PER_INCH / resolution; |
|
|
|
int j = i == 0 ? 0 : (i + 2) * UNIT.PT_PER_INCH / resolution; |
|
|
|
return j + Inter.getLocText("Unit_PT"); |
|
|
|
return j + Inter.getLocText("Unit_PT"); |
|
|
@ -203,10 +221,10 @@ public class PolyDesignUI extends ComponentUI { |
|
|
|
|
|
|
|
|
|
|
|
private void paintAddingData(Graphics g, AddingData addingData) { |
|
|
|
private void paintAddingData(Graphics g, AddingData addingData) { |
|
|
|
BlockCreator comp = addingData.getCreator(); |
|
|
|
BlockCreator comp = addingData.getCreator(); |
|
|
|
int x = addingData.getCurrentX(); |
|
|
|
int x = (int) (addingData.getCurrentX()*time); |
|
|
|
int y = addingData.getCurrentY(); |
|
|
|
int y = (int) (addingData.getCurrentY()*time); |
|
|
|
int width = comp.getWidth(); |
|
|
|
int width = (int) (comp.getWidth()*time); |
|
|
|
int height = comp.getHeight(); |
|
|
|
int height = (int) (comp.getHeight()*time); |
|
|
|
paintCreator(g, comp, x, y, width, height); |
|
|
|
paintCreator(g, comp, x, y, width, height); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -214,9 +232,16 @@ public class PolyDesignUI extends ComponentUI { |
|
|
|
ArrayList<JComponent> dbcomponents = new ArrayList<JComponent>(); |
|
|
|
ArrayList<JComponent> dbcomponents = new ArrayList<JComponent>(); |
|
|
|
// richer:禁止双缓冲行为,否则会出现两个图像
|
|
|
|
// richer:禁止双缓冲行为,否则会出现两个图像
|
|
|
|
ComponentUtils.disableBuffer(comp, dbcomponents); |
|
|
|
ComponentUtils.disableBuffer(comp, dbcomponents); |
|
|
|
Graphics clipg = g.create(x, y, width, height); |
|
|
|
// Graphics clipg = g.create(x, y, width*resolution/ScreenResolution.getScreenResolution(), height*resolution/ScreenResolution.getScreenResolution());
|
|
|
|
comp.paint(clipg); |
|
|
|
//
|
|
|
|
clipg.dispose(); |
|
|
|
BufferedImage img = CoreGraphHelper.createBufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_RGB); |
|
|
|
|
|
|
|
Graphics2D g2d = img.createGraphics(); |
|
|
|
|
|
|
|
comp.printAll(g2d); |
|
|
|
|
|
|
|
g2d.dispose(); |
|
|
|
|
|
|
|
g.drawImage(img,x,y,width,height,null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// comp.paint(clipg);
|
|
|
|
|
|
|
|
// clipg.dispose();
|
|
|
|
ComponentUtils.resetBuffer(dbcomponents); |
|
|
|
ComponentUtils.resetBuffer(dbcomponents); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|