Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Zoom on Shape Node containing Diagram View (Read 1523 times)
SandeepGowda
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Jan 6th, 2009
Zoom on Shape Node containing Diagram View
Feb 25th, 2009 at 9:26am
Print Post  
hi,
below is the code snippet for zooming the Diagram View.

// Jdiagram View
m_mainJDiagramView = new DiagramView();
m_mainJDiagramView.setLayout(new GridBagLayout());
*******************
m_mainJDiagramView.zoomToFit(new Rectangle2D.Double(50,50,50,50));
********************
m_mainDiagram = new Diagram();

m_mainDiagram.setBackBrush(new SolidBrush(new Color((int) 202,
(int) 202, (int) 202)));
m_mainDiagram.setSelectAfterCreate(false);
m_mainJDiagramView.setCursor(Cursor.getDefaultCursor());
m_mainDiagram.getUndoManager().setUndoEnabled(true);
m_mainDiagram.setGridColor(Color.black);
m_mainDiagram.setShowAnchors(ShowAnchors.Auto);
m_mainDiagram.setShowGrid(true);
m_mainDiagram.setAlignToGrid(true);
m_mainJDiagramView.setBehavior(Behavior.DrawLinks);
m_mainDiagram.setSnapToAnchor(SnapToAnchor.OnCreateOrModify);
m_mainDiagram.setShapeBrush(new SolidBrush(Color.LIGHT_GRAY));
m_mainDiagram.setMeasureUnit(GraphicsUnit.Millimeter);
m_mainDiagram.setBounds(new Rectangle2D.Float(0, 0, 380, 380));
m_mainDiagram.setAlignToGrid(true);

Node[] nodes = new Node[] {
new Node(new AnchorPattern(new AnchorPoint[] {
new AnchorPoint((short) 30, (short) 0, true, true,
MarkStyle.Circle, Color.red),
new AnchorPoint((short) 50, (short) 0, true, true,
MarkStyle.Circle, Color.red),
--
*
*
*
*
m_mainJDiagramView.setDiagram(m_mainDiagram);
// holds Jdiagram.
JideScrollPane jideJdiagramScrollPane = new JideScrollPane();

jideJdiagramScrollPane.setAutoscrolls(true);

jideJdiagramScrollPane.setBorder(lineBorder);

jideJdiagramScrollPane.getViewport().add(m_mainJDiagramView);
jideJdiagramScrollPane
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
jideJdiagramScrollPane
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
jideJdiagramScrollPane
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

Can you please help if i am wrong in implementing Zoom functionality.

regards
sandeep.

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zoom on Shape Node containing Diagram View
Reply #1 - Feb 25th, 2009 at 11:56am
Print Post  
You should call zoomToFit after the view has been added to the scrollpane. If you move the zoomToFit line to the end of that code, it should work fine. It might also be necessary the DiagramView to be already visible.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint