Permalink
Browse files

Moving around in Eclipse.

  • Loading branch information...
1 parent 83456cb commit 7b2084067913ce1a18dfc4886e1b5dd86d1d8ed3 @scooby committed May 7, 2011
View
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>visualexprbuilder</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
@@ -1,132 +0,0 @@
-/*
- Copyright 2009 Benjamin Samuel. All rights reserved.
- This file is part of VisualExpressionBuilder, a component for the
- Swing UI for Java. Java is a trademark of Sun.
-
- VisualExpressionBuilder is free software: you can redistribute it and/or
- modify it under the terms of the GNU General Public License as published
- by the Free Software Foundation, either version 3 of the License, or (at
- your option) any later version.
-
- VisualExpressionBuilder is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with VisualExpressionBuilder, in the file COPYING in the root directory of
- the distribution. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package net.samuel.ben;
-import java.awt.Graphics2D;
-
-/** A piecegroup has many pieces in a tree organization.
- * All pieces are assembled into a single unit.
- * Rows alternate border row (which includes the nib descender), content row
- * Columns alternate side column and content column.
- *
- * Like columns may be collapsed.
- * content squiggly squiggly content -> content squiggly content
-**/
-
-public class Group {
- private ExpressionUI eui;
- private ExprBuildComponent ebc;
- private double nibDescent;
- private double nibExtent;
- private double nibSpacing;
- public Group(ExprBuildComponent _ebc) {
- ebc = _ebc;
- eui = _ebc.getUI();
- nibDescent = eui.nibDescent();
- nibExtent = eui.nibExtent();
- nibSpacing = eui.nibSpacing();
- }
-
- /**
- * Set up the grid of nodes
- **/
- private void build_grid(Node root, Graphics2D g) {
- // Make sure it's really the root. The root is often an
- // UnusedReturn.
- while(root.getOut() != null)
- root = root.getOut();
- LinkedList<Node> queue;
- queue.offer(root);
- ninf.put(root, new NodeInfo(root, 0, 0));
- ArrayList<Node> all;
- int maxrow = 0;
- // Do node-widths, row numbers, and parent / older sibling links
- while(!queue.isEmpty()) {
- Node n = queue.remove();
- NodeInfo ni = ninf.get(n);
- int o = 0;
- NodeInfo os = null;
- for(Node child : n.getIns()) {
- queue.offer(child);
- os = ninf.put(child,
- new NodeInfo(child, ni.row + 1, o++, ni, os));
- }
- if(o == 0)
- n.nwidth = 1; // By default it is 0, and it gets set later...
- else
- maxrow = Math.max(maxrow, ni.row + 1);
- all.add(n);
- }
- gmap = new ArrayList<SortedMap<int, NodeInfo>>(maxrow + 1);
- for(int i = maxrow + 1; i > 0; i--)
- gmap.add(new SortedMap<int, NodeInfo>());
- Rectangle2D labelRect = new Rectangle2D.double();
- // Iterate backwards to hit the leaves first.
- // This makes leaves tell parents how wide they need to be.
- ListIterator<Node> li = all.list_iterator(all.size());
- while(li.hasPrevious()) {
- Node x = li.previous();
- NodeInfo xi = ninf.get(x);
- eui.contentArea(g, x, labelRect);
- xi.cont_width = labelRect.getWidth();
- xi.cont_height = labelRect.getHeight();
- Node px = x.getOut();
- if(px == null)
- continue;
- NodeInfo pxi = ninf.get(px);
- pxi.span += xi.span;
- pxi.chld_width += Math.max(xi.chld_width, xi.cont_width);
- }
- // Iterate forwards as a node's column is older sibling + nwidth
- li = all.list_iterator(0);
- while(li.hasNext()) {
- Node x = li.next();
- NodeInfo xi = ninf.get(x);
- if(xi.off == 0)
- xi.col = 0;
- else
- xi.col = xi.old_sib.col + xi.old_sib.span;
- gmap.get(xi.row).put(xi.col, xi);
- }
- }
-
- private ArrayList<SortedMap<int, NodeInfo>> gmap;
- private IdentityHashMap<Node, NodeInfo> ninf;
- private class NodeInfo {
- public NodeInfo(Node n, int r, int o, NodeInfo p, NodeInfo os) {
- node = n;
- row = r;
- off = o;
- parent = p;
- old_sib = os;
- nwidth = 0;
- }
- public Node node;
- public NodeInfo parent;
- public NodeInfo old_sib;
- public int row;
- public int col;
- public int off;
- public int span;
- public double cont_width;
- public double cont_height;
- public double chld_width;
- }
-}
@@ -1,85 +0,0 @@
-/*
- Copyright 2009 Benjamin Samuel. All rights reserved.
- This file is part of VisualExpressionBuilder, a component for the
- Swing UI for Java. Java is a trademark of Sun.
-
- VisualExpressionBuilder is free software: you can redistribute it and/or
- modify it under the terms of the GNU General Public License as published
- by the Free Software Foundation, either version 3 of the License, or (at
- your option) any later version.
-
- VisualExpressionBuilder is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with VisualExpressionBuilder, in the file COPYING in the root directory of
- the distribution. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.samuel.ben;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-public class OperatorFromMethod extends Operator {
- protected Method m;
- protected ArrayList<Class<?>> paramTypes;
- protected ArrayList<Node> params;
- public Operator(Method _m) {
- if(_m == null)
- throw new NullPointerException();
- super();
- m = _m;
- Class<?>[] ca = m.getParameterTypes();
- if(isStatic()) {
- paramTypes = new ArrayList<Class<?>>(Arrays.asList(ca));
- } else {
- paramTypes = new ArrayList<Class<?>>(ca.length() + 1);
- paramTypes.add(m.getDeclaringClass());
- paramTypes.addAll(Arrays.asList(ca));
- }
- params = new ArrayList<Node>(paramTypes.size());
- for(Class<?> c : paramTypes) {
- params.add(new UnsetArg(this, c));
- }
- }
- protected boolean isStatic() {
- return Modifier.isStatic(m.getModifiers());
- }
- public String getLabel() { return toString(); }
- public Class<?> getType() { return m.getReturnType(); }
- public List<? extends Node> getIns() {
- return Collections.unmodifiableList(params);
- }
- public void setIn(int arg, Node n) {
- if(arg < 0 || arg >= maxArgs())
- throw new IndexOutOfBoundsException("arg " + arg + " of " + this.toString());
- if(n == null)
- n = new UnsetArg(this, paramTypes.get(arg));
- if(paramTypes.get(arg).isAssignableFrom(n.getType()))
- params.set(arg, n);
- else
- throw new ClassCastException("arg " + arg + " of " + this.toString());
- }
- public Object getValue() {
- ArrayList<Object> values = new ArrayList<Object>(paramTypes.size());
- for(int i = 0; i < paramTypes.size(); ++i)
- values.set(i, params.get(i).getValue());
- try {
- if(isStatic())
- return m.invoke(null,
- values.toArray());
- else
- return m.invoke(values.get(0),
- values.subList(1,
- values.size()).toArray());
- } catch(Throwable t) {
- return t;
- }
- }
- public String toString() { return m.toGenericString(); }
-}
View
@@ -1,79 +0,0 @@
-/*
- Copyright 2009 Benjamin Samuel. All rights reserved.
- This file is part of VisualExpressionBuilder, a component for the
- Swing UI for Java. Java is a trademark of Sun.
-
- VisualExpressionBuilder is free software: you can redistribute it and/or
- modify it under the terms of the GNU General Public License as published
- by the Free Software Foundation, either version 3 of the License, or (at
- your option) any later version.
-
- VisualExpressionBuilder is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with VisualExpressionBuilder, in the file COPYING in the root directory of
- the distribution. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.samuel.ben;
-
-/**
- * Represents a graphical element
- */
-
-class Piece {
- public enum Draw {
- full_area, semicircle_top, semicircle_bottom,
- squiggly_side, squiggly_row, straight_side, straight_row,
- pointy_left_side, pointy_right_side, corner, empty
- }
- Piece(Node _n, Group _g) {
- n = _n; p = _p;
- }
- public void calc_dims() {
- switch(ns) {
- case squiggly_sides:
- left.d = right.d = squiggly_side;
- top.d = bot.d = squiggly_row;
- content.d = label_area;
- break;
- case straight_sides:
- left.d = right.d = straight_side;
- top.d = n.hasInputs() ? squiggly_row : straight_row;
- bot.d = squiggly_row;
- content.d = label_area;
- break;
- case pointy_sides:
- left.d = pointy_left_side;
- right.d = pointy_right_side;
- top.d = n.hasInputs() ? squiggly_row : straight_row;
- bot.d = squiggly_row;
- content.d = label_area;
- break;
- case semicircle_top:
- left.d = right.d = top.d = empty;
- bot.d = squiggly_row;
- content.d = semicircle_top;
- break;
- case semicircle_bottom:
- left.d = right.d = bot.d = empty;
- top.d = squiggly_row;
- content.d = semicircle_bottom;
- break;
- default:
- throw new RuntimeException("What?!");
- }
- }
- public Piece left() {
- }
- public Piece right() {
- }
- private float w;
- private float h;
- private Node n;
- private Group g;
- private Part p;
-}
View
@@ -1,5 +1,7 @@
+package othernotes;
+
public class HashTest {
-public static void main(String[] args) {
-System.out.println(int.class.hashCode());
-}
+ public static void main(String[] args) {
+ System.out.println(int.class.hashCode());
+ }
}
View
@@ -1,29 +0,0 @@
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.geom.*;
-import javax.swing.*;
-
-public class OnePiece2 extends JPanel {
- public Shape
-
- public void paint(Graphics g) {
- Graphics2D g2d = (Graphics2D) g;
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.translate((getBounds().getWidth() - PieceWidth()) / 2, (getBounds().getHeight() - PieceHeight()) / 2);
- g2d.setStroke(new BasicStroke(1.0f));
- g2d.draw(BorderShape());
- }
-
- public static void main(String args[]) {
- JFrame f = new JFrame("OnePiece");
- f.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {System.exit(0);}
- });
- OnePiece op = new OnePiece();
- f.getContentPane().add("Center", op);
- f.setSize(300, 300);
- f.pack();
- f.setVisible(true);
- }
-}
Oops, something went wrong.

0 comments on commit 7b20840

Please sign in to comment.