/*
* Title: japlot.jaxodraw
* Description: Graphical user interface for drawing Feynman diagrams
* @author Daniele Binosi
* @author Lukas Theussl
Copyright (C) 2003-2006, Daniele Binosi and Lukas Theussl
See the file LICENSE in the source distribution home directory
for a full copy of the GPL (GNU General Public License).
This file is part of japlot.jaxodraw.
japlot.jaxodraw 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 2 of the License, or
(at your option) any later version.
japlot.jaxodraw 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package japlot.jaxodraw;
import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/** General class that takes care of the pop up events. */
public class JaxoPopupListener extends MouseAdapter {
private JaxoMainPanel thePanel;
private int type;
private JaxoCanvasPopupMenu canvasPop;
private JaxoVertexPopupMenu vertexPop;
private JaxoGridPopupMenu gridPop;
private JaxoZoomPopupMenu zoomPop;
/** Constructor: creates the (Canvas,Vertex,Grid,Zoom) PopupMenus.
* @param mainPanel Instance of the main panel.
* @param calledFrom An integer specifying the type of popup menu
* this listener was called from.
*/
public JaxoPopupListener(JaxoMainPanel mainPanel, int calledFrom) {
this.thePanel = mainPanel;
this.type = calledFrom;
canvasPop = new JaxoCanvasPopupMenu(thePanel);
vertexPop = new JaxoVertexPopupMenu(thePanel);
zoomPop = new JaxoZoomPopupMenu(thePanel);
gridPop = new JaxoGridPopupMenu(thePanel);
}
/** Specifies the action to be taken when the mouse has been clicked on the
* current component.
* @param e The MouseEvent to be processed.
*/
public final void mouseClicked(MouseEvent e) {
if (((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0)) {
if (type == 0) {
canvasPop.setGridType();
canvasPop.show(thePanel.getCanvasPanel(), e.getX(), e.getY());
} else if (type == 1) {
vertexPop.show(thePanel.getMbtPanel(), e.getX() + 80,
e.getY() + 10);
} else if (type == 2) {
zoomPop.show(thePanel.getGbtPanel(), e.getX() + 40,
e.getY() + 10);
} else if (type == 3) {
gridPop.setGridType();
gridPop.show(thePanel.getGbtPanel(), e.getX(), e.getY() + 10);
}
}
}
/** Sets the text for the popup menus in different languages.
* @param languageString A string specifying the language to be set.
*/
public final void setLanguage(String languageString) {
if (canvasPop != null) {
canvasPop.setLanguage(languageString);
}
if (vertexPop != null) {
vertexPop.setLanguage(languageString);
}
if (zoomPop != null) {
zoomPop.setLanguage(languageString);
}
if (gridPop != null) {
gridPop.setLanguage(languageString);
}
}
/** Sets the radio button to the current vertex type in the pop-up menu.
* @param i Specifies the current vertex type.
*/
public final void updatePop(int i) {
if (type == 1) {
vertexPop.setPopupVT(i);
}
}
}
Ads help maintain this website.