Search in sources :

Example 1 with WorldPanel

use of mudmap2.frontend.GUIElement.WorldPanel.WorldPanel in project mudmap2 by Neop.

the class WorldTab method createGui.

/**
 * Creates the GUI elements
 */
private void createGui(World world, boolean passive) {
    setLayout(new BorderLayout());
    worldPanel = new WorldPanel(parentFrame, world, passive);
    add(worldPanel, BorderLayout.CENTER);
    worldPanel.addTileSiteListener(this);
    worldPanel.addStatusListener(this);
    worldPanel.addPlaceSelectionListener(new PlaceSelectionListener() {

        @Override
        public void placeSelected(Place place) {
            updateInfobar();
        }

        @Override
        public void placeDeselected(Place place) {
            updateInfobar();
        }
    });
    sidePanel = new SidePanel(world);
    add(sidePanel, BorderLayout.EAST);
    sidePanel.addLayerPanelListener(this);
    sidePanel.addPlacePanelListener(this);
    add(panelSouth = new JPanel(), BorderLayout.SOUTH);
    panelSouth.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.insets = new Insets(1, 2, 0, 2);
    // add bottom panel elements
    // previous / next buttons for the history
    JButton button_prev = new JButton("Prev");
    constraints.gridx++;
    panelSouth.add(button_prev, constraints);
    button_prev.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            worldPanel.popPosition();
        }
    });
    JButton button_next = new JButton("Next");
    constraints.gridx++;
    panelSouth.add(button_next, constraints);
    button_next.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            worldPanel.restorePosition();
        }
    });
    constraints.gridx++;
    constraints.weightx = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    panelSouth.add(labelInfobar = new ScrollLabel(), constraints);
    labelInfobar.startThread();
    // set default selected place to hte center place
    worldPanel.setCursor((int) Math.round(worldPanel.getPosition().getX()), (int) Math.round(worldPanel.getPosition().getY()));
    constraints.gridx++;
    constraints.weightx = 0.0;
    constraints.fill = GridBagConstraints.NONE;
    panelSouth.add(new JLabel("Map zoom:"), constraints);
    constraints.gridx++;
    sliderZoom = new JSlider(0, 100, (int) (100.0 / WorldPanel.TILE_SIZE_MAX * worldPanel.getTileSize()));
    panelSouth.add(sliderZoom, constraints);
    sliderZoom.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent arg0) {
            worldPanel.setTileSize((int) ((double) worldPanel.TILE_SIZE_MAX * ((JSlider) arg0.getSource()).getValue() / 100.0));
        }
    });
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) SidePanel(mudmap2.frontend.sidePanel.SidePanel) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) PlaceSelectionListener(mudmap2.frontend.GUIElement.WorldPanel.PlaceSelectionListener) WorldPanel(mudmap2.frontend.GUIElement.WorldPanel.WorldPanel) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) ScrollLabel(mudmap2.frontend.GUIElement.ScrollLabel) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener) Place(mudmap2.backend.Place)

Example 2 with WorldPanel

use of mudmap2.frontend.GUIElement.WorldPanel.WorldPanel in project mudmap2 by Neop.

the class WorldPanelTest method testGetWorld.

/**
 * Test of getWorld method, of class WorldPanel.
 */
@Test
public void testGetWorld() {
    System.out.println("getWorld");
    World world = new World();
    WorldPanel instance = new WorldPanel(null, world, false);
    assertEquals(world, instance.getWorld());
}
Also used : World(mudmap2.backend.World) Test(org.junit.Test)

Example 3 with WorldPanel

use of mudmap2.frontend.GUIElement.WorldPanel.WorldPanel in project mudmap2 by Neop.

the class WorldPanelTest method testMoveCursor.

/**
 * Test of moveCursor method, of class WorldPanel.
 */
@Test
public void testMoveCursor() {
    System.out.println("moveCursor");
    int dx = 9;
    int dy = -4;
    World world = new World();
    WorldPanel instance = new WorldPanel(null, world, false);
    instance.setCursor(4, 6);
    instance.moveCursor(4 + dx, 6 + dy);
}
Also used : World(mudmap2.backend.World) Test(org.junit.Test)

Example 4 with WorldPanel

use of mudmap2.frontend.GUIElement.WorldPanel.WorldPanel in project mudmap2 by Neop.

the class WorldPanelTest method testIsFocusForced.

/**
 * Test of isFocusForced / setFocusForced method, of class WorldPanel.
 */
@Test
public void testIsFocusForced() {
    System.out.println("isFocusForced");
    WorldPanel instance = new WorldPanel(null, new World(), false);
    assertFalse(instance.isFocusForced());
    instance.setFocusForced(true);
    assertTrue(instance.isFocusForced());
    instance.setFocusForced(false);
    assertFalse(instance.isFocusForced());
}
Also used : World(mudmap2.backend.World) Test(org.junit.Test)

Example 5 with WorldPanel

use of mudmap2.frontend.GUIElement.WorldPanel.WorldPanel in project mudmap2 by Neop.

the class WorldPanelTest method testIsCursorForced.

/**
 * Test of is/setCursorForced method, of class WorldPanel.
 */
@Test
public void testIsCursorForced() {
    System.out.println("isCursorForced");
    World world = new World();
    WorldPanel instance = new WorldPanel(null, world, false);
    boolean result = instance.isCursorForced();
    assertFalse(result);
    instance.setCursorForced(true);
    result = instance.isCursorForced();
    assertTrue(result);
    instance.setCursorForced(false);
    result = instance.isCursorForced();
    assertFalse(result);
}
Also used : World(mudmap2.backend.World) Test(org.junit.Test)

Aggregations

World (mudmap2.backend.World)15 Test (org.junit.Test)15 WorldCoordinate (mudmap2.backend.WorldCoordinate)3 Place (mudmap2.backend.Place)2 BorderLayout (java.awt.BorderLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JSlider (javax.swing.JSlider)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1 Layer (mudmap2.backend.Layer)1 ScrollLabel (mudmap2.frontend.GUIElement.ScrollLabel)1 PlaceSelectionListener (mudmap2.frontend.GUIElement.WorldPanel.PlaceSelectionListener)1 WorldPanel (mudmap2.frontend.GUIElement.WorldPanel.WorldPanel)1