📄 drawsketchframe.java
字号:
for (int i = 0; i < components.length; i++) {
addNewComponent(components[i]);
}
repaint();
} catch (Exception e1) {
log.error(e1);
e1.printStackTrace();
}
}
public void actionColorLayout(ActionEvent e) {
try {
if (image == null) { // load one image from file
String file = FileTools.showOpenDialog(cfg.getDataDir(), "jpg", "JPEG Image", true, null);
//log.debug("Analyse file: " + file);
if (file == null) {
return;
}
image = javax.imageio.ImageIO.read(new File(file));
drawPanel.setBackgroundImage(image);
}
ColorLayout colorLayout = new ColorLayout(image);
colorLayout.setNumberOfYCoeff(COLOR_LAYOUT_Y);
colorLayout.setNumberOfCCoeff(COLOR_LAYOUT_C);
Element colorLayoutElement = colorLayout.getDescriptor();
Document doc = new Document(colorLayoutElement);
repaint();
} catch (Exception e1) {
log.error(e1);
e1.printStackTrace();
}
}
public void actionClear(ActionEvent e) {
clear();
}
public void actionOpenMpeg7(ActionEvent e) {
log.warn("method " + "actionOpenMpeg7" + " not implemented");
}
public void actionSaveMpeg7(ActionEvent e) {
log.warn("method " + "actionSaveMpeg7" + " not implemented");
}
public void actionCloseDialog(ActionEvent e) {
log.warn("method " + "actionCloseDialog" + " not implemented");
}
public void actionColorPalette(ActionEvent e) {
log.warn("method " + "actionColorPalette" + " not implemented");
}
public void actionViewMpeg7(ActionEvent e) {
/*Mpeg7 mpeg7Document = generateMpeg7FromData(dataList1);
XMLTreeView view = new XMLTreeView(new JFrame(), true, mpeg7Document.getDocument((Document) null));
view.setSize(640, 480);
//view.setLocation(this.getLocation().x + 20, this.getLocation().y + 20);
view.setVisible(true);*/
}
/**
* make a list with all data extracted from the visible components
* like shape color and shape
*/
private java.util.List makeIComponentList() { // update the List of the parent
java.util.List returnValue = new Vector(1, 3);
try {
Component[] comp = drawPanel.getComponents();
for (int i = 0; i < comp.length; i++) {
if (IComponent.class.isInstance(comp[i])) {
IComponent icomp = (IComponent) comp[i];
//log.debug("ADD JCOMPONENT: " + icomp.toString());
returnValue.add(icomp);
}
}
} catch (Exception e1) {
log.error(e1);
e1.printStackTrace();
}
return returnValue;
}
private void updateData() { // update the List of the parent
try {
/*
Component[] comp = drawPanel.getComponents();
iComponentList.clear();
for (int i = 0; i < comp.length; i++) {
if (IComponent.class.isInstance(comp[i])) {
IComponent icomp = (IComponent) comp[i];
//log.debug("ADD JCOMPONENT: " + icomp.toString());
iComponentList.add(icomp);
}
} */
// note: handler of iComponent may not change !!!!
iComponentList.clear();
iComponentList.addAll(makeIComponentList());
} catch (Exception e1) {
log.error(e1);
e1.printStackTrace();
}
}
public java.util.List getiComponentList() {
return iComponentList;
}
public java.util.List<IComponentData> getDataList() {
java.util.List<IComponentData> returnValue;
returnValue = makeDataList();
return returnValue;
}
public BufferedImage getImage() {
return image;
}
public void actionDrawShape(ActionEvent e) {
try {
IShape shape1 = new IShape(drawPanel, Color.BLACK, Color.GRAY,
image, drawPanel.getBackgroundImageSize());
addNewComponent(shape1);
} catch (Exception e1) {
log.error(e1);
e1.printStackTrace();
}
}
private void addNewComponent(IComponent component1) {
drawPanel.add(component1);
component1.addMouseListener(component1);
component1.addMouseMotionListener(component1);
}
protected void finalize() throws Throwable {
super.finalize();
}
/**
* now we have an new document
*/
public void getIcomponentFromDnd(IComponent component1) {
drawPanel.addNewComponent(component1);
}
/**
* make a list with all data extracted from the visible components
* like shape color, cameraMotions and so on
*/
private java.util.List<IComponentData> makeDataList() {
java.util.List<IComponentData> returnValue = new ArrayList<IComponentData>();
try {
Component[] comp = drawPanel.getComponents();
java.util.List<IComponentData> iComponentDataList = new ArrayList<IComponentData>();
for (Component component1 : comp) {
if (IComponent.class.isInstance(component1)) {
IComponent icomp = (IComponent) component1;
//log.debug("ADD JCOMPONENT: " + icomp.toString());
iComponentDataList.add(icomp.getComponentData());
}
}
returnValue.addAll(iComponentDataList);
} catch (Exception e1) {
log.error(e1);
e1.printStackTrace();
}
return returnValue;
}
// return backgroundImage or the sketch
public BufferedImage getSketchImage() {
BufferedImage returnValue = null;
if (image == null) {
return returnValue;
}
try {
BufferedImage similarityImage;
//updateData();
java.util.List componentList = makeIComponentList();
similarityImage = image;
if (!(componentList == null) && !(componentList.size() == 0)) {
IComponent[] compArray = new IComponent[componentList.size()];
int counter;
counter = 0;
for (Iterator it = componentList.iterator(); it.hasNext();) {
IComponent icomp = (IComponent) it.next();
IComponent clone = (IComponent) icomp.clone();
if (IShape.class.isInstance(clone)) {
IShape shape = (IShape) clone;
shape.setDoDrawEffectOnMouseOver(false);
shape.setDoDrawBorder(false);
}
clone.setDrawPanel(this.drawPanel);
clone.setMoveable(true);
clone.setResizeable(true);
clone.setDoDnd(false);
compArray[counter] = clone;
counter++;
} // end for
similarityImage = java2dTools.javaObjectsToImage(compArray);
returnValue = similarityImage;
}
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use Options | File Templates.
}
return returnValue;
}
public void actionViewMetadataImage(ActionEvent e) {
BufferedImage similarityImage;
similarityImage = getSketchImage();
/*
java.util.List componentList = makeIComponentList();
similarityImage = image;
if (!(componentList == null) && !(componentList.size() == 0)) {
IComponent[] compArray = new IComponent[componentList.size()];
int counter;
counter = 0;
for (Iterator it = componentList.iterator(); it.hasNext();) {
IComponent icomp = (IComponent) it.next();
IComponent clone = (IComponent) icomp.clone();
clone.setDrawPanel(this.drawPanel);
clone.setMoveable(true);
clone.setResizeable(true);
clone.setDoDnd(false);
compArray[counter] = clone;
counter++;
} // end for
similarityImage = java2dTools.javaObjectsToImage(compArray);
*/
java2dTools.showImage(similarityImage);
//} // end if
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -