Refactor some classes, delete obsolete exceptions
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package mimis.exception;
|
||||
|
||||
public class EventException extends Exception {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package mimis.exception.event.router;
|
||||
|
||||
import mimis.exception.event.SpreaderException;
|
||||
import mimis.exception.EventException;
|
||||
|
||||
public class GlobalRouterException extends SpreaderException {
|
||||
public class GlobalRouterException extends EventException {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
45
java/exec.mimis/src/main/java/mimis/util/Swing.java
Normal file
45
java/exec.mimis/src/main/java/mimis/util/Swing.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package mimis.util;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public class Swing {
|
||||
protected static ClassLoader classLoader;
|
||||
protected static Toolkit toolkit;
|
||||
|
||||
static {
|
||||
classLoader = Swing.class.getClassLoader();
|
||||
toolkit = Toolkit.getDefaultToolkit();
|
||||
}
|
||||
|
||||
public static URL getResource(String name) {
|
||||
return classLoader.getResource(name);
|
||||
}
|
||||
|
||||
public static Image getImage(String name) {
|
||||
return toolkit.getImage(getResource(name));
|
||||
}
|
||||
|
||||
public static ImageIcon getImageIcon(String name) {
|
||||
return new ImageIcon(getResource(name));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package mimis.util.swing;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import base.util.ArrayCycle;
|
||||
|
||||
public class CycleButton extends HoldButton {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
protected ArrayCycle<ImageIcon> imageIconCycle;
|
||||
|
||||
public CycleButton(HoldButtonListener holdButtonListener, ArrayCycle<ImageIcon> imageIconCycle) {
|
||||
super(holdButtonListener);
|
||||
this.imageIconCycle = imageIconCycle;
|
||||
cycle();
|
||||
}
|
||||
|
||||
public void cycle() {
|
||||
setIcon(imageIconCycle.current());
|
||||
imageIconCycle.next();
|
||||
}
|
||||
}
|
||||
34
java/exec.mimis/src/main/java/mimis/util/swing/Dialog.java
Normal file
34
java/exec.mimis/src/main/java/mimis/util/swing/Dialog.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package mimis.util.swing;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class Dialog {
|
||||
public static final String TITLE = "MIMIS Dialog";
|
||||
|
||||
public static String question(String message, Object initial) {
|
||||
return question(TITLE, message, initial);
|
||||
}
|
||||
|
||||
public static String question(String title, String message, Object initial) {
|
||||
return (String) JOptionPane.showInputDialog(
|
||||
null, message, title,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null, null, initial);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package mimis.util.swing;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
||||
public class HoldButton extends JButton implements MouseListener {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
protected HoldButtonListener holdButtonListener;
|
||||
|
||||
public HoldButton(HoldButtonListener holdButtonListener) {
|
||||
this.holdButtonListener = holdButtonListener;
|
||||
addMouseListener(this);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent event) {
|
||||
if (event.getButton() == MouseEvent.BUTTON1) {
|
||||
holdButtonListener.buttonPressed(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent event) {
|
||||
if (event.getButton() == MouseEvent.BUTTON1) {
|
||||
holdButtonListener.buttonReleased(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent event) {}
|
||||
public void mouseEntered(MouseEvent event) {}
|
||||
public void mouseExited(MouseEvent event) {}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package mimis.util.swing;
|
||||
|
||||
public interface HoldButtonListener {
|
||||
public void buttonPressed(HoldButton button);
|
||||
public void buttonReleased(HoldButton button);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package mimis.util.swing;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import base.util.ArrayCycle;
|
||||
|
||||
public class ToggleButton extends CycleButton {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
public ToggleButton(HoldButtonListener holdButtonListener, ImageIcon firstImageIcon, ImageIcon secondImageIcon) {
|
||||
super(holdButtonListener, new ArrayCycle<ImageIcon>(firstImageIcon, secondImageIcon));
|
||||
}
|
||||
|
||||
public void toggle() {
|
||||
cycle();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user