ポイントのジオメトリを取得し、このジオメトリ「bornes」の行が選択されると色を変更する形状に基づいてグラフィックを描画しようとしています。問題は、行を選択するたびにこのエラーが発生することです。ログ ファイルは次のとおりです。あらかじめ
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)
これは、このエラーに関連するコード行です。これは、bornes (名前、X、Y) を含むbornesTable のリスナーで発生します。
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();
}
}
});
メソッドは次のとおりです: selectedBornes()
public Geometry selectedBornes() {
if (getSelectedRowIndex()> 0)
{
Geometry geometry;
geometry = searchBorne().get(getSelectedRowIndex()).getGeometry();
return geometry;
}
return null;
}
メソッド serchBornes() には問題はありませんが、投稿します
private List<BasicFeature> searchBorne() {
final List<BasicFeature> basicFeatureBornes = new ArrayList<BasicFeature>();
for(BasicFeature basicFeature : BornesList) {
if ( searchProperties.getNumTextField().getText().equals(basicFeature.getString("num")) &&
searchProperties.getComplementComboBox().getSelectedItem().equals(basicFeature.getString("complement")))
basicFeatureBornes.add(basicFeature);
}
return basicFeatureBornes;
}
メソッド getSelectedRowIndex() もこれに問題はありませんが、投稿します
public int getSelectedRowIndex() {
int row = 0;
for(int i = 0; i < searchBorne().size() ; i++ ) {
row = searchProperties.getBornesTable().getSelectedRow();
}
return row;
}