use of org.twak.utils.ui.ListDownLayout in project chordatlas by twak.
the class PlanesGen method selected.
private void selected(Plane p) {
JPanel ui = new JPanel(new ListDownLayout());
JButton delete = new JButton("delete");
delete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
planes.remove(p);
PlanesGen.this.calculateOnJmeThread();
}
});
ui.add(delete);
tweed.frame.setGenUI(ui);
}
use of org.twak.utils.ui.ListDownLayout in project chordatlas by twak.
the class ProfileGen method getUI.
@Override
public JComponent getUI() {
JSlider slider = new JSlider(JSlider.HORIZONTAL, -1, gNode.getChildren().size(), -1);
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
tweed.enqueue(new Runnable() {
@Override
public void run() {
int value = slider.getValue();
for (Spatial s : gNode.getChildren()) {
if (s instanceof Node) {
Integer i = s.getUserData(ProfileGen.class.getSimpleName());
if (i != null && s instanceof Node)
if (value == -1 || i == value)
s.setCullHint(CullHint.Inherit);
else
s.setCullHint(CullHint.Always);
}
}
tweed.gainFocus();
}
});
}
});
JButton skel = new JButton("optimize");
skel.addActionListener(ae -> doSkel());
JComboBox<Mode> vizMode = new JComboBox<>(Mode.values());
vizMode.addActionListener(e -> doViz((Mode) vizMode.getSelectedItem()));
// JButton writeProfiles = new JButton("dump profs");
// writeProfiles.addActionListener( ae -> writeProfiles() );
JButton stateBuilder = new JButton("segmenter ui");
stateBuilder.addActionListener(ae -> new SSBuilder(this, tweed.features));
JButton profs = new JButton("2d profiles");
profs.addActionListener(ae -> new ProfileAssignmentViewer(faces));
JPanel out = new JPanel(new ListDownLayout());
out.add(skel);
out.add(new JLabel("profiles rendered:"));
out.add(slider);
out.add(new JLabel("viz:"));
out.add(vizMode);
// out.add( writeProfiles );
out.add(stateBuilder);
out.add(profs);
return out;
}
use of org.twak.utils.ui.ListDownLayout in project chordatlas by twak.
the class ResultsGen method getUI.
@Override
public JComponent getUI() {
JPanel out = new JPanel();
out.setLayout(new ListDownLayout());
JButton all = new JButton("load all");
all.addActionListener(e -> new Thread(() -> load(root, false)).start());
out.add(all);
JButton clear = new JButton("clear");
clear.addActionListener(e -> clear());
out.add(clear);
return out;
}
use of org.twak.utils.ui.ListDownLayout in project chordatlas by twak.
the class FacadeTool method getUI.
@Override
public void getUI(JPanel panel) {
panel.setLayout(new ListDownLayout());
JComboBox<GISGen.Mode> allOne = new JComboBox<>();
allOne.addItem(GISGen.Mode.RENDER_ALL_BLOCKS);
allOne.addItem(GISGen.Mode.RENDER_SELECTED_BLOCK);
// allOne.addItem( GISGen.Mode.RENDER_SAT );
allOne.setSelectedItem(GISGen.mode);
allOne.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
GISGen.mode = (Mode) allOne.getSelectedItem();
}
});
JComboBox<FacadeFinder.FacadeMode> granularity = new JComboBox<>();
granularity.addItem(FacadeMode.PER_GIS);
granularity.addItem(FacadeMode.PER_MEGA);
granularity.addItem(FacadeMode.PER_CAMERA);
granularity.addItem(FacadeMode.PER_CAMERA_CROPPED);
granularity.setSelectedItem(FacadeFinder.facadeMode);
granularity.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FacadeFinder.facadeMode = (FacadeMode) granularity.getSelectedItem();
}
});
// JButton render = new JButton( "render" );
// render.addActionListener( new ActionListener() {
// @Override
// public void actionPerformed( ActionEvent e ) {
// renderFacades(null);
// }
// } );
// panel.add( render );
panel.add(allOne);
panel.add(granularity);
panel.add(new JLabel("click on any block to start"));
}
use of org.twak.utils.ui.ListDownLayout in project chordatlas by twak.
the class Slice method buildUI.
private void buildUI() {
ma = new PanMouseAdaptor(this);
ma.center(new Point2d((max[flatAxis[0]] - min[flatAxis[0]]) / 2 + min[flatAxis[0]], (max[flatAxis[1]] - min[flatAxis[1]]) / 2 + min[flatAxis[1]]));
ma.setZoom(16);
JFrame jf = new JFrame("slice");
WindowManager.register(jf);
jf.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// System.exit(0);
}
});
jf.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(600, 600));
jf.add(this, BorderLayout.CENTER);
final JSlider heightSlider = new JSlider(SwingConstants.VERTICAL, (int) (min[majorAxis] * sliderScale), (int) (max[majorAxis] * sliderScale), (int) ((max[majorAxis] - min[majorAxis]) * 0.5 + min[majorAxis]) * sliderScale);
final JSlider lineSlider = new JSlider(SwingConstants.VERTICAL, -1, 50, -1);
heightSlider.setPaintLabels(false);
final ChangeListener cl;
heightSlider.addChangeListener(cl = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent arg0) {
sliceHeight = heightSlider.getValue() / (double) sliderScale;
LineSoup rawSoup = sliceMesh(rawMesh, sliceHeight);
slice = sliceMesh(filteredMesh, sliceHeight);
foundLines = new FindLines(slice, gisBias, lineSlider.getValue(), rawSoup.clique(P.CL_HIGH, P.CL_LOW), P);
Concarnie cc = new Concarnie(foundLines.result, foundLines.cliques, P);
// Concarnie cc = new Concarnie(slice, rawSoup.clique() );
carnieSoup = cc.graph;
carnie = cc.out;
Slice.this.repaint();
}
});
cl.stateChanged(null);
lineSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
cl.stateChanged(null);
}
});
final JSlider parameterScaleSlider = new JSlider(SwingConstants.VERTICAL, 0, 2000, (int) (P.getScale() * 100));
parameterScaleSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
P.setScale(parameterScaleSlider.getValue() / 100.);
}
});
JButton go = new JButton("support");
go.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
setupObj(new ObjRead(toSlice));
// supportPoints.clear();
// Slice.this.repaint();
// SwingUtilities.invokeLater(new Runnable() {
// @Override
// public void run() {
// PerpSupport ps = new PerpSupport(slice, gis);
// Slice.this.supportMax = ps.supportMax;
// Slice.this.supportPoints = ps.supportPoints;
// Slice.this.repaint();
// }
// });
}
});
JButton fs = new JButton("full support");
fs.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
Set<Point2d> points = new HashSet();
for (double v = min[majorAxis]; v < max[majorAxis]; v += 0.01) {
System.out.println("processing slice " + v + " / " + max[majorAxis]);
slice = sliceMesh(filteredMesh, sliceHeight);
for (SupportPoint sp : new PerpSupport(slice, gis).supportPoints) points.add(new Point2d(sp.support, max[majorAxis] - v));
}
System.out.println("found " + points.size() + " pts");
new Plot(points);
}
});
JButton ge = new JButton("lines");
ge.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
foundLines = new FindLines(slice, gisBias, lineSlider.getValue(), slice.clique(P.CL_HIGH, P.CL_LOW), P);
Slice.this.repaint();
}
});
JButton cc = new JButton("carnie");
cc.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
LineSoup rawSoup = sliceMesh(rawMesh, sliceHeight);
foundLines = new FindLines(slice, gisBias, lineSlider.getValue(), rawSoup.clique(P.CL_HIGH, P.CL_LOW), P);
Concarnie cc = new Concarnie(foundLines.result, foundLines.cliques, P);
carnieSoup = cc.graph;
carnie = cc.out;
Slice.this.repaint();
}
});
JButton ob = new JButton("dump");
ob.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
ObjDump out = new ObjDump();
double delta = 2.5;
for (double d = min[majorAxis]; d <= max[majorAxis]; d += delta) {
System.out.println(d + " / " + max[majorAxis]);
boolean error;
int count = 0;
do {
error = false;
try {
LineSoup rawSoup = sliceMesh(rawMesh, d);
slice = sliceMesh(filteredMesh, d);
foundLines = new FindLines(slice, null, lineSlider.getValue(), rawSoup.clique(P.CL_HIGH, P.CL_LOW), P);
// foundLines = new FindLines(slice, gisBias, lineSlider.getValue(), rawSoup.clique(P.CL_HIGH, P.CL_LOW), P);
Concarnie c = new Concarnie(foundLines.result, foundLines.cliques, P);
//
extrude(out, c.out, d, d + delta);
// capAtHeight (out, c.out, false, d );
capAtHeight(out, c.out, true, d + delta);
} catch (Throwable th) {
error = true;
}
} while (error && count++ < 10);
}
out.dump(new File(Tweed.SCRATCH + "test2.obj"));
}
});
JButton an = new JButton("anim");
an.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
BufferedImage bi = new BufferedImage(Slice.this.getWidth(), Slice.this.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
for (File f : new File(Tweed.SCRATCH + "vid").listFiles()) f.delete();
int c = 0;
for (int i = heightSlider.getMinimum(); i < heightSlider.getMaximum(); i += 100) {
heightSlider.setValue(i);
Slice.this.paintComponent(bi.getGraphics());
try {
ImageIO.write(bi, "png", new File(String.format(Tweed.SCRATCH + "vid/%05d.png", c++)));
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
JButton sl = new JButton("global");
sl.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
new SliceSolver(new File(Tweed.SCRATCH + "test2.obj"), Slice.this, P);
}
});
JButton pr = new JButton("profiles");
pr.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
double delta = 0.5;
BufferedImage out = new BufferedImage(Slice.this.getWidth(), Slice.this.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2 = (Graphics2D) out.getGraphics();
g2.setColor(Color.white);
g2.fillRect(0, 0, getWidth(), getHeight());
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(new Color(0, 0, 0, 50));
for (double d = min[majorAxis]; d <= max[majorAxis]; d += delta) {
System.out.println(d + " / " + max[majorAxis]);
boolean error;
int count = 0;
do {
error = false;
try {
LineSoup rawSoup = sliceMesh(rawMesh, d);
slice = sliceMesh(filteredMesh, d);
FindLines fl = new FindLines(slice, gisBias, lineSlider.getValue(), rawSoup.clique(P.CL_HIGH, P.CL_LOW), P);
PaintThing.paint(fl.result, g2, ma);
// Concarnie c = new Concarnie(foundLines.result, foundLines.cliques, P);
} catch (Throwable th) {
error = true;
}
} while (error && count++ < 10);
}
g2.dispose();
try {
ImageIO.write(out, "png", new File(Tweed.SCRATCH + "lines"));
} catch (IOException e) {
e.printStackTrace();
}
}
});
final JCheckBox sg = new JCheckBox("gis", true);
sg.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
showGis = sg.isSelected();
Slice.this.repaint();
}
});
final JCheckBox sf = new JCheckBox("fit", true);
sf.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
showFit = sf.isSelected();
Slice.this.repaint();
}
});
final JCheckBox sc = new JCheckBox("poly-out", true);
sc.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
showCarnie = sc.isSelected();
Slice.this.repaint();
}
});
final JCheckBox ss = new JCheckBox("slice", true);
ss.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
showSlice = ss.isSelected();
Slice.this.repaint();
}
});
JPanel buttons = new JPanel(new ListDownLayout());
buttons.add(go);
buttons.add(fs);
buttons.add(ge);
buttons.add(cc);
buttons.add(an);
buttons.add(ob);
buttons.add(sl);
buttons.add(pr);
buttons.add(sg);
buttons.add(sf);
buttons.add(sc);
buttons.add(ss);
buttons.add(lineSlider);
JPanel controls = new JPanel(new BorderLayout());
controls.add(heightSlider, BorderLayout.CENTER);
controls.add(parameterScaleSlider, BorderLayout.WEST);
controls.add(buttons, BorderLayout.EAST);
jf.add(controls, BorderLayout.EAST);
jf.pack();
jf.setVisible(true);
}
Aggregations