Первый раз позирует при переполнении стека, так что извините за пропущенные соглашения.Дайте мне знать, и я исправлю их.
У меня проблемы с программным управлением моими моделями.Я полагаю, что это вызвано тем, что imageio не может прочитать файл изображения в банке или во внешнем проекте, и я не могу найти способ исправить это.
Когда я обычно запускаю модель, все в порядке, нокогда я запускаю его программно из другого проекта, я получаю:
Сначала предупреждение:
log4j:WARN No appenders could be found for logger (org.java.plugin.boot.DefaultPluginsCollector).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Затем запускается графический интерфейс, и когда я нажимаю «Start Run» или «Initialize Run», я получаю:
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Caught NullPointerException: null on thread AWT-EventQueue-0
, за которым последовало множество других, которые, как мне кажется, не имеют здесь значения, поскольку я прочитал статью рассылки repast sourceforge, где они сказали с этой ошибкой / предупреждением, что журнал ошибок графического интерфейса - это вещь для чтения.Регистратор в графическом интерфейсе читает:
2019/03/05 09:12:32,297: Error while initializing edited style
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at repast.simphony.visualizationOGL2D.ImageSpatialSource.registerSource(ImageSpatialSource.java:52)
at repast.simphony.visualization.editedStyle.EditedStyleOGL2D.init(EditedStyleOGL2D.java:95)
at repast.simphony.visualizationOGL2D.DisplayOGL2D.registerStyle(DisplayOGL2D.java:475)
at repast.simphony.visualization.engine.DisplayCreatorOGL2D$2.register(DisplayCreatorOGL2D.java:81)
at repast.simphony.visualization.engine.DisplayCreatorOGL2D$2.register(DisplayCreatorOGL2D.java:1)
at repast.simphony.visualization.engine.StyleRegistrar.registerStyles(StyleRegistrar.java:93)
at repast.simphony.visualization.engine.StyleRegistrar.registerStyles(StyleRegistrar.java:34)
at repast.simphony.visualization.engine.DisplayCreatorOGL2D.createDisplay(DisplayCreatorOGL2D.java:79)
at repast.simphony.visualization.engine.DisplayProducer.createDisplay(DisplayProducer.java:48)
at repast.simphony.visualization.engine.DisplayComponentControllerAction.runInitialize(DisplayComponentControllerAction.java:116)
at repast.simphony.engine.controller.DefaultController$2.visit(DefaultController.java:214)
at repast.simphony.engine.controller.DefaultController$2.visit(DefaultController.java:1)
at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:292)
at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:295)
at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:295)
at repast.simphony.util.collections.NaryTree.preOrderTraversal(NaryTree.java:288)
at repast.simphony.engine.controller.DefaultController.runInitialize(DefaultController.java:212)
at repast.simphony.engine.controller.DefaultController.runInitialize(DefaultController.java:383)
at repast.simphony.ui.RSApplication.initSim(RSApplication.java:157)
at repast.simphony.ui.action.InitRun.actionPerformed(InitRun.java:17)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Код ошибки (в модели) для этой ошибки должен быть:
@Override
public Context build(Context<Object> context) {
try {
img = ImageIO.read(new File("maps/trondheimv2.png"));
} catch (IOException e) {
System.out.println(e + ": Image file not found!");
}
...
Я пытался использовать абсолютный путь:
C:/Users/USER/Documents/Git/REPO/Traffic_Main/maps/trondheimv2.png
и этот метод:
getClass().getResource("C:/Users/USER/Documents/Git/REPO/Traffic_Main/maps/trondheimv2.png").toURI()));
Я использую переименованную версию примера FAQ для программного запуска модели:
package execute;
public class UserMain {
public UserMain () {};
public void start () {
String [] args = new String []{ "C:/Users/USERNAME/Documents/Git/REPO/Traffic_Main/CitySim.rs"};
repast . simphony . runtime . RepastMain . main ( args ) ;
}
public static void main ( String [] args ) {
UserMain um = new UserMain () ;
um . start () ;
}
}
Класс находится в другом проектев C: / Users / ИМЯ ПОЛЬЗОВАТЕЛЯ / Documents / Git / REPO / Runner / src / execute
Я добавил банки из repast.simphony.runtime_2.6.0 / lib и добавил repast.simphony.runtime_2.6.0Папка / bin в classpath.
Моя цель - запустить несколько моделей из проекта Runner
Спасибо за потраченное время.
edit: внесены изменения, предложенные Eric Tatara и получил следующие ошибки:
WARN [AWT-EventQueue-0] 11:04:59,452 repast.simphony.ui.RSGUIConstants - Error loading: player_play, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,453 repast.simphony.ui.RSGUIConstants - Error loading: player_pause, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,454 repast.simphony.ui.RSGUIConstants - Error loading: player_stop, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,455 repast.simphony.ui.RSGUIConstants - Error loading: player_step, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,455 repast.simphony.ui.RSGUIConstants - Error loading: project_open, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,455 repast.simphony.ui.RSGUIConstants - Error loading: filesave, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,456 repast.simphony.ui.RSGUIConstants - Error loading: filesave16, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,456 repast.simphony.ui.RSGUIConstants - Error loading: filter16, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,457 repast.simphony.ui.RSGUIConstants - Error loading: reload, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,457 repast.simphony.ui.RSGUIConstants - Error loading: exec, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,457 repast.simphony.ui.RSGUIConstants - Error loading: folder, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,458 repast.simphony.ui.RSGUIConstants - Error loading: folder_open, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,458 repast.simphony.ui.RSGUIConstants - Error loading: camera, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,458 repast.simphony.ui.RSGUIConstants - Error loading: movie, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,459 repast.simphony.ui.RSGUIConstants - Error loading: chart, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,459 repast.simphony.ui.RSGUIConstants - Error loading: database, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,460 repast.simphony.ui.RSGUIConstants - Error loading: display, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,460 repast.simphony.ui.RSGUIConstants - Error loading: info_viz, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,460 repast.simphony.ui.RSGUIConstants - Error loading: kudesigner, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,461 repast.simphony.ui.RSGUIConstants - Error loading: lockstart_session, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,461 repast.simphony.ui.RSGUIConstants - Error loading: leaf, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,462 repast.simphony.ui.RSGUIConstants - Error loading: edit, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,462 repast.simphony.ui.RSGUIConstants - Error loading: home, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,462 repast.simphony.ui.RSGUIConstants - Error loading: info, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,463 repast.simphony.ui.RSGUIConstants - Error loading: view_sidetree, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,463 repast.simphony.ui.RSGUIConstants - Error loading: harddrive, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,463 repast.simphony.ui.RSGUIConstants - Error loading: button_cancel, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,464 repast.simphony.ui.RSGUIConstants - Error loading: edit_add, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,464 repast.simphony.ui.RSGUIConstants - Error loading: apply, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,464 repast.simphony.ui.RSGUIConstants - Error loading: redo, it will not be used.
FATAL [AWT-EventQueue-0] 11:04:59,545 repast.simphony.ui.RSUIPlugin - Fatal error starting Repast
java.lang.NoSuchMethodError: com.jgoodies.forms.layout.ColumnSpec.createGap(Lcom/jgoodies/forms/layout/ConstantSize;)Lcom/jgoodies/forms/layout/ColumnSpec;
at com.jgoodies.forms.layout.FormSpecs.<clinit>(FormSpecs.java:115)
at repast.simphony.ui.RunOptionsPanel.initComponents(RunOptionsPanel.java:114)
at repast.simphony.ui.RunOptionsPanel.<init>(RunOptionsPanel.java:39)
at repast.simphony.ui.RSGui.addRunOptionsView(RSGui.java:558)
at repast.simphony.ui.RSApplication.initGui(RSApplication.java:655)
at repast.simphony.ui.RSAppConfigurator.fillBars(RSAppConfigurator.java:52)
at saf.core.ui.GUICreatorDelegate.createDisplay(GUICreatorDelegate.java:189)
at saf.core.ui.GUICreator.createDisplay(GUICreator.java:12)
at repast.simphony.ui.RSUIPlugin$1.run(RSUIPlugin.java:99)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
at java.awt.image.BufferedImage.<init>(Unknown Source)
at repast.simphony.ui.widget.IconRotator.rotate(IconRotator.java:51)
at repast.simphony.ui.widget.IconRotator.access$0(IconRotator.java:47)
at repast.simphony.ui.widget.IconRotator$1.actionPerformed(IconRotator.java:32)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)