Note that there are some explanatory texts on larger screens.

plurals
  1. PODrawing a shape with draw graphic method?
    primarykey
    data
    text
    <p>am trying to draw a graphic based on a shape that gets geometry of a point and change it's color once the row of this geometry "bornes" is selected the problem is i get this error every time i select a row here's the log file: thanks in advance</p> <pre><code> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.vividsolutions.jump.workbench.ui.renderer.java2D.Java2DConverter.toShape(Java2DConverter.java:313) at com.vividsolutions.jump.workbench.ui.plugin.specific.SearchPropertiesPlugin$2.valueChanged(SearchPropertiesPlugin.java:144) at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167) at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:147) at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:194) at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:388) at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:398) at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:442) at javax.swing.JTable.changeSelectionModel(JTable.java:2352) at javax.swing.JTable.changeSelection(JTable.java:2421) at javax.swing.plaf.basic.BasicTableUI$Handler.adjustSelection(BasicTableUI.java:1085) at javax.swing.plaf.basic.BasicTableUI$Handler.mousePressed(BasicTableUI.java:1008) at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:263) at java.awt.Component.processMouseEvent(Component.java:6294) at javax.swing.JComponent.processMouseEvent(JComponent.java:3275) at java.awt.Component.processEvent(Component.java:6062) at java.awt.Container.processEvent(Container.java:2039) at java.awt.Component.dispatchEventImpl(Component.java:4660) at java.awt.Container.dispatchEventImpl(Container.java:2097) at java.awt.Component.dispatchEvent(Component.java:4488) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4575) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4233) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4166) at java.awt.Container.dispatchEventImpl(Container.java:2083) at java.awt.Window.dispatchEventImpl(Window.java:2489) at java.awt.Component.dispatchEvent(Component.java:4488) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:668) at java.awt.EventQueue.access$400(EventQueue.java:81) at java.awt.EventQueue$2.run(EventQueue.java:627) at java.awt.EventQueue$2.run(EventQueue.java:625) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98) at java.awt.EventQueue$3.run(EventQueue.java:641) at java.awt.EventQueue$3.run(EventQueue.java:639) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:638) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) </code></pre> <p>here's the lines of the code concerned by this error, it happens in the listener of the bornesTable that contains the bornes (Name, X, Y) </p> <pre><code> searchProperties.getBornesTable().getSelectionModel().addListSelectionListener(new ListSelectionListener(){ @Override public void valueChanged(ListSelectionEvent e) { try { if (search()!= null){ // here's the line 144 in toShape() method final Shape shape = context.getLayerViewPanel().getViewport().getJava2DConverter().toShape(selectedBornes()); Color color = Color.yellow; Stroke stroke =new BasicStroke(5, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND); final Graphics2D graphics = (Graphics2D) context.getLayerViewPanel().getGraphics(); graphics.setColor(color); //graphics.setXORMode(Color.white); graphics.setStroke(stroke); graphics.fill(shape); } else JOptionPane.showMessageDialog(null, "vous n'avez pas selectionner une bornes " ); } catch (NoninvertibleTransformException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); </code></pre> <p>here's the method: selectedBornes()</p> <pre><code> public Geometry selectedBornes() { if (getSelectedRowIndex()&gt; 0) { Geometry geometry; geometry = searchBorne().get(getSelectedRowIndex()).getGeometry(); return geometry; } return null; } </code></pre> <p>and the method serchBornes() there's no problem with this but i'll post it </p> <pre><code> private List&lt;BasicFeature&gt; searchBorne() { final List&lt;BasicFeature&gt; basicFeatureBornes = new ArrayList&lt;BasicFeature&gt;(); for(BasicFeature basicFeature : BornesList) { if ( searchProperties.getNumTextField().getText().equals(basicFeature.getString("num")) &amp;&amp; searchProperties.getComplementComboBox().getSelectedItem().equals(basicFeature.getString("complement"))) basicFeatureBornes.add(basicFeature); } return basicFeatureBornes; } </code></pre> <p>and the method getSelectedRowIndex() there's no problem with this too, but i'll post it</p> <pre><code> public int getSelectedRowIndex() { int row = 0; for(int i = 0; i &lt; searchBorne().size() ; i++ ) { row = searchProperties.getBornesTable().getSelectedRow(); } return row; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload