Trying to use processing in eclipse
in
Integration and Hardware
•
3 years ago
I have been creating a project in eclipse that is essentially a network map of connections between people (each person is a node, and it graphs connections between people by drawing edges between nodes). I created it in Processing, and am now trying to move it over to eclipse. It works fine in Processing, and in eclipse, as a Java Applet, it shows only a gray area. However, as a Java Application in Eclipse, it works fine, except the image shown is not in the center of the screen, but rather is in the bottom right and the edges are cut off. How do I re-position the image created into the Java Application box?
Thanks
Relevant code attached:
- public void setup() {
- size(260, 160);
- if (showEdges)
- defaultEdgeColor = edgeColor;
- else
- defaultEdgeColor = noEdgeColor;
- c = new GUIController (this, true);
- familyBtn = new IFButton ("Show family only", 40, 40, 180, 17);
- nonfamilyBtn = new IFButton ("Show non-family only", 40, 70, 180, 17);
- allBtn = new IFButton ("Show all", 40, 100, 180, 17);
- familyBtn.addActionListener(this);
- nonfamilyBtn.addActionListener(this);
- allBtn.addActionListener(this);
- c.add (familyBtn);
- c.add (nonfamilyBtn);
- c.add (allBtn);
- }
- public void runProgram() {
- c.setVisible (false);
- loadData();
- font = createFont("Serif-48.vlw", 10);
- writeData();
- size(scrX, scrY);
- frame.setSize(scrX, scrY);
- createNodes();
- running = true;
- }
- public void createNodes() {
- if (record) {
- beginRecord(PDF, "output.pdf");
- }
- background(255);
- textFont(font);
- smooth();
- Iterator iter = (Iterator)edges.iterator();
- while (iter.hasNext()){
- Edge e = (Edge)iter.next();
- e.relax();
- }
- iter = (Iterator)nodes.iterator();
- while (iter.hasNext()){
- Node v = (Node)iter.next();
- v.relax();
- }
- iter = (Iterator)nodes.iterator();
- while (iter.hasNext()){
- Node v = (Node)iter.next();
- v.update();
- }
- iter = (Iterator)edges.iterator();
- while (iter.hasNext()){
- Edge e = (Edge)iter.next();
- // e.eColor = noEdgeColor;
- e.draw();
- }
- iter = (Iterator)nodes.iterator();
- while (iter.hasNext()){
- Node v = (Node)iter.next();
- v.draw();
- }
- if (record) {
- endRecord();
- record = false;
- }
- }
- public void draw() {
- if(running)
- {
- createNodes();
- }
- }
1