[Nextobjects-devel] nextobjects/nextobjects/src/org/devaki/nextobjects/util NOClipboard.java,1.6,1.7
Status: Alpha
Brought to you by:
eflorent
|
From: <efl...@us...> - 2003-06-13 17:23:12
|
Update of /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/util
In directory sc8-pr-cvs1:/tmp/cvs-serv21894/src/org/devaki/nextobjects/util
Modified Files:
NOClipboard.java NOImageTransform.java
Log Message:
Made very big models a little bit faster.
Index: NOClipboard.java
===================================================================
RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/util/NOClipboard.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** NOClipboard.java 9 Jun 2003 19:06:06 -0000 1.6
--- NOClipboard.java 13 Jun 2003 17:23:07 -0000 1.7
***************
*** 274,280 ****
if (pCurrentObjects.elementAt(i) instanceof Label)
{
! Label tObject =new Label((Label) pCurrentObjects.elementAt(i));
v.addElement(tObject);
! }
}
ObjectSelection contents = new ObjectSelection(v);
--- 274,280 ----
if (pCurrentObjects.elementAt(i) instanceof Label)
{
! Label tObject = new Label((Label) pCurrentObjects.elementAt(i));
v.addElement(tObject);
! }
}
ObjectSelection contents = new ObjectSelection(v);
***************
*** 335,339 ****
newObject);
ModelMan.addCurrentObject(newObject);
-
} else if (clippedObject instanceof Association)
{
--- 335,338 ----
***************
*** 357,369 ****
newObject.getObjectView().setLocation(new Point(x, y));
ModelMan.addCurrentObject(newObject);
! } else if (clippedObject instanceof Label)
! {
! Label newObject =
! new Label((Label) clippedObject);
- ModelMan.addLabel(ModelMan.getCurrentModel(),newObject);
- newObject.getObjectView().setLocation(new Point(x, y));
- ModelMan.addCurrentObject(newObject);
-
} else if (ModelMan.getCurrentModel() instanceof PhysicalModel)
{
--- 356,370 ----
newObject.getObjectView().setLocation(new Point(x, y));
ModelMan.addCurrentObject(newObject);
! } else if (clippedObject instanceof Label)
! {
! Label newObject = new Label((Label) clippedObject);
!
! ModelMan.addLabel(
! ModelMan.getCurrentModel(),
! newObject);
! newObject.getObjectView().setLocation(new Point(x, y));
! ModelMan.addCurrentObject(newObject);
! }
} else if (ModelMan.getCurrentModel() instanceof PhysicalModel)
{
***************
*** 389,582 ****
} else if (clippedObject instanceof Label)
{
! Label newObject =
! new Label((Label) clippedObject);
ModelMan.addLabel(
((PhysicalModel) ModelMan.getCurrentModel()),
newObject);
! newObject.getObjectView().setLocation(new Point(x, y));
ModelMan.addCurrentObject(newObject);
- }
}
}
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error(
! "UnsupportedFlavorException : Cannot get transfer data");
! }
}
! /**
! * Paste a field contained in the clipboard
! * @param object the column to paste
! */
! public static void pasteColumn(BaseObject object)
{
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
! {
! Column clippedObject =
! (Column) clipboardContent.getTransferData(Column.fieldFlavor);
! clippedObject.setParent(object);
! // Add element to the given object
! object.getData().addElement(clippedObject);
! // Reload tree from the parent node
! NOTreeView.reloadBaseClassChildrens(
! clippedObject.getParent().getDynamicTreeNode());
! // Repaint associate model only if it is the current model
! if (clippedObject.getParent().getMyModel().getPanel().isShowing())
! {
! ModelMan.getCurrentModel().getPanel().repaint();
! }
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
{
! logger.error(
! "UnsupportedFlavorException : Cannot get transfer data");
}
}
! /**
! * Paste clipped style
! * @param pEntityView clipped style
! */
! public static void pasteEntityStyle(EntityView pEntityView)
{
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
! {
! EntityStyle clippedObject =
! (EntityStyle) clipboardContent.getTransferData(
! EntityStyle.fieldFlavor);
! pEntityView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error(
! "UnsupportedFlavorException : Cannot get transfer data");
! }
}
! /**
! * Paste clipped style
! * @param pTableView clipped style
! */
! public static void pasteTableStyle(TableView pTableView)
{
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
! {
! TableStyle clippedObject =
! (TableStyle) clipboardContent.getTransferData(
! TableStyle.fieldFlavor);
! pTableView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error(
! "UnsupportedFlavorException : Cannot get transfer data");
! }
}
! /**
! * Paste clipped style
! * @param pAssociationView clipped style
! */
! public static void pasteAssociationStyle(AssociationView pAssociationView)
{
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
! {
! AssociationStyle clippedObject =
! (AssociationStyle) clipboardContent.getTransferData(
! AssociationStyle.fieldFlavor);
! pAssociationView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error(
! "UnsupportedFlavorException : Cannot get transfer data");
! }
}
! /**
! * Paste clipped style
! * @param pAssociationLinkView clipped style
! */
! public static void pasteAssociationLinkStyle(AssociationLinkView pAssociationLinkView)
{
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
! {
! AssociationLinkStyle clippedObject =
! (AssociationLinkStyle) clipboardContent.getTransferData(
! AssociationLinkStyle.fieldFlavor);
! pAssociationLinkView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error(
! "UnsupportedFlavorException : Cannot get transfer data");
! }
}
! /**
! * Paste clipped style
! * @param pInheritanceLinkView clipped style
! */
! public static void pasteInheritanceLinkStyle(InheritanceLinkView pInheritanceLinkView)
{
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
! {
! InheritanceLinkStyle clippedObject =
! (InheritanceLinkStyle) clipboardContent.getTransferData(
! InheritanceLinkStyle.fieldFlavor);
! pInheritanceLinkView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error(
! "UnsupportedFlavorException : Cannot get transfer data");
! }
}
! /**
! * Paste clipped style
! * @param pConstraintView clipped style
! */
! public static void pasteConstraintStyle(ConstraintView pConstraintView)
{
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
! {
! ConstraintStyle clippedObject =
! (ConstraintStyle) clipboardContent.getTransferData(
! ConstraintStyle.fieldFlavor);
! pConstraintView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error(
! "UnsupportedFlavorException : Cannot get transfer data");
! }
}
}
--- 390,573 ----
} else if (clippedObject instanceof Label)
{
! Label newObject = new Label((Label) clippedObject);
ModelMan.addLabel(
((PhysicalModel) ModelMan.getCurrentModel()),
newObject);
! newObject.getObjectView().setLocation(new Point(x, y));
ModelMan.addCurrentObject(newObject);
}
}
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error("UnsupportedFlavorException : Cannot get transfer data");
}
+ }
! /**
! * Paste a field contained in the clipboard
! * @param object the column to paste
! */
! public static void pasteColumn(BaseObject object)
! {
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
{
! Column clippedObject =
! (Column) clipboardContent.getTransferData(Column.fieldFlavor);
! clippedObject.setParent(object);
! // Add element to the given object
! object.getData().addElement(clippedObject);
! // Reload tree from the parent node
! NOTreeView.reloadBaseClassChildrens(
! clippedObject.getParent().getDynamicTreeNode());
! // Repaint associate model only if it is the current model
! if (clippedObject.getParent().getMyModel().getPanel().isShowing())
{
! ModelMan.getCurrentModel().getPanel().repaint();
}
+ } catch (IOException ioe)
+ {
+ logger.error("IOException : Cannot get transfer data");
+ } catch (UnsupportedFlavorException ufe)
+ {
+ logger.error("UnsupportedFlavorException : Cannot get transfer data");
}
+ }
! /**
! * Paste clipped style
! * @param pEntityView clipped style
! */
! public static void pasteEntityStyle(EntityView pEntityView)
! {
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
{
! EntityStyle clippedObject =
! (EntityStyle) clipboardContent.getTransferData(
! EntityStyle.fieldFlavor);
! pEntityView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error("UnsupportedFlavorException : Cannot get transfer data");
}
+ }
! /**
! * Paste clipped style
! * @param pTableView clipped style
! */
! public static void pasteTableStyle(TableView pTableView)
! {
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
{
! TableStyle clippedObject =
! (TableStyle) clipboardContent.getTransferData(
! TableStyle.fieldFlavor);
! pTableView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error("UnsupportedFlavorException : Cannot get transfer data");
}
+ }
! /**
! * Paste clipped style
! * @param pAssociationView clipped style
! */
! public static void pasteAssociationStyle(AssociationView pAssociationView)
! {
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
{
! AssociationStyle clippedObject =
! (AssociationStyle) clipboardContent.getTransferData(
! AssociationStyle.fieldFlavor);
! pAssociationView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error("UnsupportedFlavorException : Cannot get transfer data");
}
+ }
! /**
! * Paste clipped style
! * @param pAssociationLinkView clipped style
! */
! public static void pasteAssociationLinkStyle(AssociationLinkView pAssociationLinkView)
! {
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
{
! AssociationLinkStyle clippedObject =
! (AssociationLinkStyle) clipboardContent.getTransferData(
! AssociationLinkStyle.fieldFlavor);
! pAssociationLinkView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error("UnsupportedFlavorException : Cannot get transfer data");
}
+ }
! /**
! * Paste clipped style
! * @param pInheritanceLinkView clipped style
! */
! public static void pasteInheritanceLinkStyle(InheritanceLinkView pInheritanceLinkView)
! {
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
{
! InheritanceLinkStyle clippedObject =
! (InheritanceLinkStyle) clipboardContent.getTransferData(
! InheritanceLinkStyle.fieldFlavor);
! pInheritanceLinkView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error("UnsupportedFlavorException : Cannot get transfer data");
}
+ }
! /**
! * Paste clipped style
! * @param pConstraintView clipped style
! */
! public static void pasteConstraintStyle(ConstraintView pConstraintView)
! {
! Transferable clipboardContent = clipboard.getContents(myClipboard);
! try
{
! ConstraintStyle clippedObject =
! (ConstraintStyle) clipboardContent.getTransferData(
! ConstraintStyle.fieldFlavor);
! pConstraintView.setStyle(clippedObject);
! } catch (IOException ioe)
! {
! logger.error("IOException : Cannot get transfer data");
! } catch (UnsupportedFlavorException ufe)
! {
! logger.error("UnsupportedFlavorException : Cannot get transfer data");
}
+ }
}
Index: NOImageTransform.java
===================================================================
RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/util/NOImageTransform.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** NOImageTransform.java 8 Jun 2003 09:28:26 -0000 1.7
--- NOImageTransform.java 13 Jun 2003 17:23:07 -0000 1.8
***************
*** 30,36 ****
import org.apache.log4j.Logger;
import org.devaki.nextobjects.workspace.models.BaseModel;
- import org.devaki.nextobjects.workspace.models.PhysicalModel;
- import org.devaki.nextobjects.workspace.models.ConceptualModel;
- import org.devaki.nextobjects.workspace.models.objects.BaseObject;
import org.devaki.nextobjects.workspace.models.graphics.ObjectView;
import org.devaki.nextobjects.workspace.models.graphics.ClassView;
--- 30,33 ----
***************
*** 103,136 ****
panel.paint(g2);
//dispose of the graphics content
!
return bi;
}
/**
! * Write Conceptual Model the model to a PNG file
! * @param pCDM the context model
* @param file the file to write
* @return success
*/
! public static boolean writeImage(ConceptualModel pCDM, File file)
{
boolean success = false;
! Point oldP = pCDM.getModelView().getRectangle().getLocation();
// this is a hack, the model is moved to top left corner in
// order to avoid drawing the whole 5000*5000 drawingArea.
// then the model is returned to old position.
// by that time it havn't been redrawed ...
! translateModel(pCDM, oldP.x, oldP.y);
! pCDM.getModelView().calculateRectangle();
! pCDM.getModelView().setFullRefresh(true);
// the rectangle give the offfset.
! Rectangle rect = pCDM.getModelView().getRectangle();
! pCDM.getModelView().setFullRefresh(true);
BufferedImage bi =
getImage(
! pCDM.getModelView().drawingArea,
rect.width,
rect.height);
--- 100,135 ----
panel.paint(g2);
//dispose of the graphics content
! g2.dispose();
return bi;
}
/**
! * Write Base Model the model to a PNG file
! * @param pModel the context model
* @param file the file to write
* @return success
*/
! public static boolean writeImage(BaseModel pModel, File file)
{
boolean success = false;
! Point oldP = pModel.getModelView().getRectangle().getLocation();
// this is a hack, the model is moved to top left corner in
// order to avoid drawing the whole 5000*5000 drawingArea.
// then the model is returned to old position.
// by that time it havn't been redrawed ...
! translateModel(pModel, oldP.x, oldP.y);
! pModel.getModelView().calculateRectangle();
! pModel.getModelView().setFullRefresh(true);
// the rectangle give the offfset.
! Rectangle rect = pModel.getModelView().getRectangle();
! pModel.getModelView().jScrollPane.getViewport().setViewPosition(rect.getLocation());
! pModel.getModelView().jScrollPane.getViewport().setViewSize(rect.getSize());
! pModel.getModelView().setFullRefresh(true);
BufferedImage bi =
getImage(
! pModel.getModelView().drawingArea,
rect.width,
rect.height);
***************
*** 145,199 ****
e.printStackTrace();
}
! translateModel(pCDM, -oldP.x, -oldP.y);
! pCDM.getModelView().calculateRectangle();
! pCDM.getModelView().setFullRefresh(true);
! pCDM.getModelView().repaint();
! pCDM.getModelView().repaint();
! return success;
! }
!
! /**
! * Write Physical Model the model to a PNG file
! * @param pPDM the context model
! * @param file the file to write
! * @return success
! */
! public static boolean writeImage(PhysicalModel pPDM, File file)
! {
! boolean success = false;
!
! Point oldP = pPDM.getModelView().getRectangle().getLocation();
! // this is a hack, the model is moved to top left corner in
! // order to avoid drawing the whole 5000*5000 drawingArea.
! // then the model is returned to old position.
! // by that time it havn't been redrawed ...
! translateModel(pPDM, oldP.x, oldP.y);
! pPDM.getModelView().calculateRectangle();
! pPDM.getModelView().setFullRefresh(true);
! // the rectangle give the offfset.
! Rectangle rect = pPDM.getModelView().getRectangle();
!
! try
! {
! BufferedImage bi =
! getImage(
! pPDM.getModelView().drawingArea,
! rect.width,
! rect.height);
! success = javax.imageio.ImageIO.write(bi, "PNG", file);
!
! } catch (Exception e)
! {
! logger.error(e.getMessage());
! // most often lacks of jdk1.4
! e.printStackTrace();
! }
! // return to the old offset.
! translateModel(pPDM, -oldP.x, -oldP.y);
! pPDM.getModelView().calculateRectangle();
! pPDM.getModelView().setFullRefresh(true);
! pPDM.getModelView().repaint();
!
return success;
}
! }
\ No newline at end of file
--- 144,153 ----
e.printStackTrace();
}
! translateModel(pModel, -oldP.x, -oldP.y);
! pModel.getModelView().calculateRectangle();
! pModel.getModelView().setFullRefresh(true);
! pModel.getModelView().jScrollPane.getViewport().setViewPosition(oldP);
! pModel.getModelView().repaint();
return success;
}
! }
|