当前位置: 首页 > 工具软件 > JGraph > 使用案例 >

cellview java_jsp:错误提示:java.lang.NoClassDefFoundError: org/jgraph/graph/CellViewFactory

王宜
2023-12-01

源代码:packagesamples.javabean;importorg.jgraph.JGraph;importorg.jgraph.graph.DefaultCellViewFactory;importorg.jgraph.graph.DefaultGraphCell;importorg.jgraph.graph.Defau...

源代码:

package samples.javabean;

import org.jgraph.JGraph;

import org.jgraph.graph.DefaultCellViewFactory;

import org.jgraph.graph.DefaultGraphCell;

import org.jgraph.graph.DefaultGraphModel;

import org.jgraph.graph.DefaultPort;

import org.jgraph.graph.GraphConstants;

import org.jgraph.graph.GraphLayoutCache;

import org.jgraph.graph.GraphModel;

public class Graphic {

String webroot;

String filename;

String random;

public Graphic(){

webroot="F:\\workspace\\test1";

filename = "number.png";

}

public String getFilename(){

return filename;

}

public void setFilename(String filename){

this.filename = filename;

}

public String getRandom(){

return random;

}

public void setRandom(){

this.random = random;

}

public void paint(){

GraphModel model = new DefaultGraphModel();

GraphLayoutCache view = new GraphLayoutCache(model,new DefaultCellViewFactory());

JGraph graph= new JGraph(model,view);

DefaultGraphCell cell = new DefaultGraphCell(random);

GraphConstants.setBounds(cell.getAttributes(),new Rectangle2D.Double(0,0,100,400));

GraphConstants.setGradientColor( cell.getAttributes(),Color.orange);

GraphConstants.setOpaque(cell.getAttributes(),true);

DefaultPort port = new DefaultPort();

cell.add(port);

graph.getGraphLayoutCache().insert(cell);

JFrame frame = new JFrame();

frame.getContentPane().add(new JScrollPane(graph));

frame.pack();

frame.setVisible(false);

try{

File f = new File(webroot,filename);

ImageOutputStream ios = ImageIO.createImageOutputStream(f);

BufferedImage img = graph.getImage(graph.getBackground(),1);

ImageIO.write(img,"png",ios);

ios.flush();

ios.close();

}catch(IOException e){

e.printStackTrace();

}

}

}

展开

 类似资料: