Search in sources :

Example 1 with Pair

use of mudmap2.utils.Pair in project mudmap2 by Neop.

the class ExportImageDialog method updateImageSize.

/**
 * Updates the displayed image size
 */
void updateImageSize() {
    if (centerPosition == null) {
        centerPosition = new WorldCoordinate(worldTab.getWorldPanel().getPosition());
    }
    Pair<Integer, Integer> imageSize = new Pair<>(0, 0);
    if (rbCurrentView.isSelected()) {
        imageSize.first = worldTab.getWorldPanel().getWidth();
        imageSize.second = worldTab.getWorldPanel().getHeight();
    } else if (rbCurrentMap.isSelected()) {
        Layer layer = worldTab.getWorld().getLayer(centerPosition.getLayer());
        imageSize = getMapSize(layer);
    } else if (rbAllMaps.isSelected()) {
        for (Layer layer : worldTab.getWorld().getLayers()) {
            // get largest image by area
            Pair<Integer, Integer> imageSize2 = getMapSize(layer);
            if (imageSize.first * imageSize.second < imageSize2.first * imageSize2.second) {
                imageSize = imageSize2;
            }
        }
    } else if (rbSelection.isSelected()) {
        HashSet<Place> places = worldTab.getWorldPanel().placeGroupGetSelection();
        imageSize = getSelectionSize(places);
    }
    imageWidth = imageSize.first;
    imageHeight = imageSize.second;
    lImageSize.setText("Image size: " + imageWidth + "x" + imageHeight + "px");
}
Also used : WorldCoordinate(mudmap2.backend.WorldCoordinate) Layer(mudmap2.backend.Layer) Pair(mudmap2.utils.Pair) HashSet(java.util.HashSet)

Example 2 with Pair

use of mudmap2.utils.Pair in project mudmap2 by Neop.

the class MapPainterDefault method getExitOffset.

/**
 * Calculates the offset of the exit visualization (dot/circle) to the
 * upper left corner of a tile
 * @param dir eit direction
 * @return false if the dot/circle doesn't have to be drawn
 */
private Pair<Integer, Integer> getExitOffset(String dir) {
    Pair<Integer, Integer> ret = new Pair<>(0, 0);
    int borderWidth = getTileBorderWidth();
    switch(dir) {
        case "n":
            // north
            ret.first = tileSize / 2;
            ret.second = borderWidth;
            break;
        case "e":
            // east
            ret.first = tileSize - borderWidth;
            ret.second = tileSize / 2;
            break;
        case "s":
            // south
            ret.first = tileSize / 2;
            ret.second = tileSize - borderWidth;
            break;
        case "w":
            // west
            ret.first = borderWidth;
            ret.second = tileSize / 2;
            break;
        case "ne":
            // north-east
            ret.first = tileSize - borderWidth;
            ret.second = borderWidth;
            break;
        case "se":
            // south-east
            ret.first = ret.second = tileSize - borderWidth;
            break;
        case "nw":
            // north-west
            ret.first = ret.second = borderWidth;
            break;
        case "sw":
            // south-west
            ret.first = borderWidth;
            ret.second = tileSize - borderWidth;
            break;
        default:
            ret.first = ret.second = tileSize / 2;
            break;
    }
    return ret;
}
Also used : GradientPaint(java.awt.GradientPaint) Pair(mudmap2.utils.Pair)

Example 3 with Pair

use of mudmap2.utils.Pair in project mudmap2 by Neop.

the class MapPainterDefault method paint.

@Override
public void paint(Graphics g, int tileSize, double graphicsWidth, double graphicsHeight, Layer layer, WorldCoordinate curPos) {
    this.graphicsWidth = graphicsWidth;
    this.graphicsHeight = graphicsHeight;
    this.tileSize = tileSize;
    this.curPos = curPos;
    tileFont = g.getFont();
    final float selectionStrokeWidth = getTileSelectionStrokeWidth();
    final int tileBorderWidthScaled = getTileBorderWidth();
    // max number of text lines tht fit in a tile
    FontMetrics fm = g.getFontMetrics();
    final int maxLines = (int) Math.round((double) (tileSize - 3 * (tileBorderWidthScaled + (int) Math.ceil(getRiskLevelStrokeWidth()))) / fm.getHeight());
    final int maxLineLength = tileSize - 2 * (tileBorderWidthScaled + (int) selectionStrokeWidth + (int) Math.ceil(getRiskLevelStrokeWidth()));
    final Boolean drawText = fm.stringWidth("WW") < (tileSize - 2 * (getRiskLevelStrokeWidth() + getTileBorderWidth()));
    // screen center in world coordinates
    // note: wdtwd2
    final double screenCenterX = (graphicsWidth / tileSize) / 2.0;
    final double screenCenterY = (graphicsHeight / tileSize) / 2.0;
    final int placeXOffset = (int) (Math.round((float) curPos.getX()) - Math.round(screenCenterX));
    final int placeYOffset = (int) (Math.round((float) curPos.getY()) - Math.floor(screenCenterY));
    // more precalculation
    final double placeXpxConst = remint(screenCenterX) - remint(curPos.getX());
    final double placeYPXConst = remint(screenCenterY) + remint(curPos.getY());
    // prepare graphic for paths
    // Paths will be drawn on this graphic and later on copied to g
    // to mask out the tile positions on graphic_path
    ArrayList<Pair<Integer, Integer>> tilePositions = new ArrayList<>();
    BufferedImage imagePath = new BufferedImage((int) graphicsWidth, (int) graphicsHeight, BufferedImage.TYPE_INT_ARGB);
    Graphics graphicPath = imagePath.getGraphics();
    ((Graphics2D) graphicPath).setStroke(new BasicStroke(getPathStrokeWidth()));
    ((Graphics2D) graphicPath).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    // getPlace the locations of copied places
    HashSet<Pair<Integer, Integer>> copiedPlaceLocations = mudmap2.CopyPaste.getCopyPlaceLocations();
    // clear screen
    if (backgroundColor == null) {
        g.clearRect(0, 0, (int) graphicsWidth + 1, (int) graphicsHeight + 1);
    } else {
        g.setColor(backgroundColor);
        g.fillRect(0, 0, (int) graphicsWidth + 1, (int) graphicsHeight + 1);
    }
    // ------------------ draw the grid --------------------------------
    if (isGridEnabled()) {
        g.setColor(Color.lightGray);
        for (int tileX = (g.getClipBounds().x / tileSize) - 1; tileX < graphicsWidth / tileSize + 1; ++tileX) {
            final int x = (int) Math.round((tileX + placeXpxConst) * tileSize);
            g.drawLine(x, 0, x, (int) graphicsHeight);
        }
        for (int tileY = (g.getClipBounds().y / tileSize) - 1; tileY < graphicsHeight / tileSize + 1; ++tileY) {
            final int y = (int) Math.round((tileY + placeYPXConst) * tileSize);
            g.drawLine(0, y, (int) graphicsWidth, y);
        }
    }
    // ------------------ draw the tiles / places ----------------------
    for (int tileX = (g.getClipBounds().x / tileSize) - 1; tileX < graphicsWidth / tileSize + 1; ++tileX) {
        for (int tileY = (g.getClipBounds().y / tileSize) - 1; tileY < graphicsHeight / tileSize + 1; ++tileY) {
            // place position on the map
            final int placeX = tileX + placeXOffset;
            final int placeY = (int) (graphicsHeight / tileSize) - tileY + placeYOffset;
            if (layer != null && layer.exist(placeX, placeY)) {
                Place curPlace = layer.get(placeX, placeY);
                // place position in pixel on the screen
                final int placeXpx = (int) Math.round((tileX + placeXpxConst) * tileSize);
                final int placeYpx = (int) Math.round((tileY + placeYPXConst) * tileSize);
                tilePositions.add(new Pair<>(placeXpx, placeYpx));
                // number of drawn text lines
                int lineNum = 0;
                // draw place group color
                if (curPlace.getPlaceGroup() != null) {
                    g.setColor(curPlace.getPlaceGroup().getColor());
                    g.fillRect(placeXpx, placeYpx, tileSize, tileSize);
                }
                // draw tile center color
                if (drawText) {
                    g.setColor(layer.getWorld().getTileCenterColor());
                    g.fillRect(placeXpx + tileBorderWidthScaled, placeYpx + tileBorderWidthScaled, tileSize - 2 * tileBorderWidthScaled, tileSize - 2 * tileBorderWidthScaled);
                }
                // draw risk level border
                if (curPlace.getRiskLevel() != null) {
                    g.setColor(curPlace.getRiskLevel().getColor());
                    ((Graphics2D) g).setStroke(new BasicStroke(getRiskLevelStrokeWidth()));
                    g.drawRect(placeXpx + tileBorderWidthScaled, placeYpx + tileBorderWidthScaled, tileSize - 2 * tileBorderWidthScaled - (int) (0.5 * getRiskLevelStrokeWidth()), tileSize - 2 * tileBorderWidthScaled - (int) (0.5 * getRiskLevelStrokeWidth()));
                }
                LinkedList<String> text = new LinkedList<>();
                String flags = "", exits = "";
                // draw text, if tiles are large enough
                if (drawText) {
                    g.setColor(Color.BLACK);
                    // place name
                    // gets place name if unique, else place name with ID
                    String placeName;
                    switch(layer.getWorld().getShowPlaceId()) {
                        default:
                        case UNIQUE:
                        case NONE:
                            // name only
                            placeName = curPlace.getName();
                            break;
                        case ALL:
                            // name and id
                            placeName = curPlace.toString();
                            break;
                    }
                    text.add(placeName);
                    int reclvlmin = curPlace.getRecLevelMin(), reclvlmax = curPlace.getRecLevelMax();
                    if (reclvlmin > -1 || reclvlmax > -1) {
                        String levelString = "lvl " + (reclvlmin > -1 ? reclvlmin : "?") + " - " + (reclvlmax > -1 ? reclvlmax : "?");
                        text.add(levelString);
                    }
                    // parents
                    if (lineNum < maxLines && !curPlace.getParents().isEmpty()) {
                        int parentsNum = curPlace.getParents().size();
                        String paStr = "Pa" + (parentsNum > 1 ? " (" + curPlace.getParents().size() + "): " : ": ");
                        boolean firstParent = true;
                        for (Place parent : curPlace.getParents()) {
                            paStr += (firstParent ? "" : ", ") + parent.getName();
                            firstParent = false;
                        }
                        text.add(paStr);
                    }
                    // children
                    if (lineNum < maxLines && !curPlace.getChildren().isEmpty()) {
                        int childrenNum = curPlace.getChildren().size();
                        String chStr = "Ch" + (childrenNum > 1 ? " (" + curPlace.getChildren().size() + "): " : ": ");
                        boolean firstChild = true;
                        for (Place child : curPlace.getChildren()) {
                            chStr += (firstChild ? "" : ", ") + child.getName();
                            firstChild = false;
                        }
                        text.add(chStr);
                    }
                    // flags
                    if (lineNum < maxLines) {
                        // place has comments
                        if (!curPlace.getComments().isEmpty())
                            flags += "Co";
                        if (!curPlace.getChildren().isEmpty())
                            flags += "Ch";
                        if (!curPlace.getParents().isEmpty())
                            flags += "Pa";
                        // other flags
                        for (Map.Entry<String, Boolean> flag : curPlace.getFlags().entrySet()) {
                            if (flag.getValue())
                                flags += flag.getKey().toUpperCase();
                            if (fm.stringWidth(flags) >= tileSize - 2 * tileBorderWidthScaled)
                                break;
                        }
                    }
                }
                // mark place group selection
                if (isSelected(curPlace) || (mudmap2.CopyPaste.isCut() && mudmap2.CopyPaste.isMarked(curPlace))) {
                    g.setColor(new Color(255, 255, 255, 128));
                    g.fillRect(placeXpx, placeYpx, tileSize, tileSize);
                }
                // draw path lines here
                boolean exitUp = false, exitDown = false, exitnstd = false;
                if (getShowPaths()) {
                    for (Path path : curPlace.getPaths()) {
                        Place otherPlace = path.getOtherPlace(curPlace);
                        Color colorPlace1 = layer.getWorld().getPathColor(path.getExitDirections()[0]);
                        Color colorPlace2 = layer.getWorld().getPathColor(path.getExitDirections()[1]);
                        if (path.getPlaces()[0] != curPlace) {
                            Color tmp = colorPlace1;
                            colorPlace1 = colorPlace2;
                            colorPlace2 = tmp;
                        }
                        // usually the main place (path.getPlaces()[0]) draws the path. If it isn't on screen, the other place draws it
                        if (Objects.equals(otherPlace.getLayer().getId(), layer.getId()) && (path.getPlaces()[0] == curPlace || !isOnScreen(otherPlace))) {
                            Pair<Integer, Integer> exitOffset = getExitOffset(path.getExit(curPlace));
                            Pair<Integer, Integer> exitOffsetOther = getExitOffset(path.getExit(otherPlace));
                            boolean drawCurves = getPathsCurved();
                            // exit positions on the map
                            final double exit1x = placeXpx + exitOffset.first;
                            final double exit1y = placeYpx + exitOffset.second;
                            final double exit2x = placeXpx + (otherPlace.getX() - curPlace.getX()) * tileSize + exitOffsetOther.first;
                            final double exit2y = placeYpx - (otherPlace.getY() - curPlace.getY()) * tileSize + exitOffsetOther.second;
                            if (colorPlace1.equals(colorPlace2)) {
                                // same color
                                ((Graphics2D) graphicPath).setPaint(colorPlace1);
                            } else {
                                // draw gradient
                                GradientPaint gp = new GradientPaint((float) exit1x, (float) exit1y, colorPlace1, (float) exit2x, (float) exit2y, colorPlace2);
                                ((Graphics2D) graphicPath).setPaint(gp);
                            }
                            if (drawCurves) {
                                Pair<Double, Double> normal1 = getExitNormal(path.getExit(curPlace));
                                Pair<Double, Double> normal2 = getExitNormal(path.getExit(otherPlace));
                                double dx = exit2x - exit1x;
                                double dy = exit2y - exit1y;
                                if (drawCurves = Math.sqrt(dx * dx + dy * dy) >= 1.5 * tileSize) {
                                    CubicCurve2D c = new CubicCurve2D.Double();
                                    // point 1
                                    c.setCurve(exit1x, exit1y, // point 2
                                    exit1x + normal1.first * tileSize, exit1y - normal1.second * tileSize, // point 3
                                    exit2x + normal2.first * tileSize, exit2y - normal2.second * tileSize, // point 4
                                    exit2x, exit2y);
                                    ((Graphics2D) graphicPath).draw(c);
                                }
                            }
                            if (!drawCurves) {
                                graphicPath.drawLine((int) exit1x, (int) exit1y, (int) exit2x, (int) exit2y);
                            }
                        }
                        // draw exit dots, if tiles are larger than 20
                        if (tileSize >= 20) {
                            g.setColor(colorPlace1);
                            String exit = path.getExit(curPlace);
                            switch(exit) {
                                case "u":
                                    exitUp = true;
                                    break;
                                case "d":
                                    exitDown = true;
                                    break;
                                default:
                                    Pair<Integer, Integer> exitOffset = getExitOffset(exit);
                                    if (exitOffset.first != tileSize / 2 || exitOffset.second != tileSize / 2) {
                                        int exitCircleRadius2 = getExitCircleRadius();
                                        g.fillOval(placeXpx + exitOffset.first - exitCircleRadius2, placeYpx + exitOffset.second - exitCircleRadius2, 2 * exitCircleRadius2, 2 * exitCircleRadius2);
                                    } else {
                                        // non-standard exit
                                        exitnstd = true;
                                    }
                                    break;
                            }
                        }
                    }
                }
                // draw exits
                if (tileSize >= 20 && (exitUp || exitDown) && drawText && lineNum <= maxLines) {
                    // have some arrows: ⬆⬇ ↑↓
                    exits = "" + (exitnstd ? "+" : "") + (exitUp ? "↑" : "") + (exitDown ? "↓" : "");
                }
                g.setColor(Color.BLACK);
                final int border = (int) (tileBorderWidthScaled + getRiskLevelStrokeWidth());
                drawText(g, placeXpx + border, placeYpx + border, tileSize - 2 * border, tileSize - 2 * border, text, flags, exits);
            }
            // TODO: extract from parent loop
            if (copiedPlaceLocations != null) {
                boolean locationFound = false;
                for (Pair<Integer, Integer> location : copiedPlaceLocations) {
                    if (location.first == placeX - placeSelectedX && location.second == placeY - placeSelectedY) {
                        locationFound = true;
                        break;
                    }
                }
                if (locationFound) {
                    // alternative: getScreenPosX();
                    int placeXpx = (int) ((tileX + remint(screenCenterX) - remint(curPos.getX())) * tileSize);
                    int placeYpx = (int) ((tileY + remint(screenCenterY) + remint(curPos.getY())) * tileSize);
                    drawCursor(g, Color.BLUE, placeXpx, placeYpx, selectionStrokeWidth);
                }
            }
            // draw cursor / place selection
            if (placeSelectionEnabled && placeX == placeSelectedX && placeY == placeSelectedY) {
                // alternative: getScreenPosX();
                int placeXpx = (int) ((tileX + remint(screenCenterX) - remint(curPos.getX())) * tileSize);
                int placeYpx = (int) ((tileY + remint(screenCenterY) + remint(curPos.getY())) * tileSize);
                drawCursor(g, TILE_SELECTION_COLOR, placeXpx, placeYpx, selectionStrokeWidth);
            }
        }
    }
    // mask out tile positions on graphicPath
    ((Graphics2D) graphicPath).setBackground(new Color(0, 0, 0, 0));
    int clearTileSize = tileSize - 2 * tileBorderWidthScaled;
    for (Pair<Integer, Integer> p : tilePositions) // graphicPath.clearRect(p.first, p.second, p.first + tileSize, p.second + tileSize);
    graphicPath.clearRect(p.first + tileBorderWidthScaled, p.second + tileBorderWidthScaled, clearTileSize, clearTileSize);
    // draw graphicPath to g
    if (getShowPaths())
        g.drawImage(imagePath, 0, 0, null);
    graphicPath.dispose();
}
Also used : BasicStroke(java.awt.BasicStroke) ArrayList(java.util.ArrayList) GradientPaint(java.awt.GradientPaint) BufferedImage(java.awt.image.BufferedImage) FontMetrics(java.awt.FontMetrics) CubicCurve2D(java.awt.geom.CubicCurve2D) Pair(mudmap2.utils.Pair) Path(mudmap2.backend.Path) Color(java.awt.Color) GradientPaint(java.awt.GradientPaint) LinkedList(java.util.LinkedList) Graphics2D(java.awt.Graphics2D) Graphics(java.awt.Graphics) HashMap(java.util.HashMap) Map(java.util.Map) Place(mudmap2.backend.Place)

Example 4 with Pair

use of mudmap2.utils.Pair in project fabric8 by fabric8io.

the class YamlTest method testParseYaml.

@Test
public void testParseYaml() throws Exception {
    String basedir = System.getProperty("basedir", ".");
    File file = new File(basedir, "src/test/resources/fabric8.yml");
    assertThat(file).exists();
    ProjectConfig config = ProjectConfigs.parseProjectConfig(file);
    System.out.println("Parsed: " + config);
    assertThat(config.getChatRoom()).isEqualTo("myroom");
    assertThat(config.getIssueProjectName()).isEqualTo("foo");
    assertThat(config.getPipeline()).isEqualTo("maven/CanaryReleaseThenStage.groovy");
    LinkedHashMap<String, String> environments = config.getEnvironments();
    // lets assert that things are in the correct order...
    List<Pair<String, String>> expectedEnvironents = Arrays.asList(new Pair<String, String>("Testing", "gogsadmin-james4-testing"), new Pair<String, String>("Staging", "gogsadmin-james4-staging"), new Pair<String, String>("Production", "gogsadmin-james4-prod"));
    int idx = 0;
    Set<Map.Entry<String, String>> entries = environments.entrySet();
    for (Map.Entry<String, String> entry : entries) {
        String key = entry.getKey();
        String value = entry.getValue();
        System.out.println("Found environment " + key + " = " + value);
        Pair<String, String> actual = new Pair<>(key, value);
        assertTrue("Too many entries - found unexpected value: " + actual, expectedEnvironents.size() > idx);
        Pair<String, String> expected = expectedEnvironents.get(idx++);
        assertEquals("environment " + idx, expected, actual);
    }
}
Also used : File(java.io.File) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Pair(io.fabric8.utils.Pair) Test(org.junit.Test)

Example 5 with Pair

use of mudmap2.utils.Pair in project mudmap2 by Neop.

the class EditWorldDialog method create.

@Override
void create() {
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    GridBagConstraints constraints_l = new GridBagConstraints();
    GridBagConstraints constraints_r = new GridBagConstraints();
    constraints.insets = constraints_l.insets = constraints_r.insets = new Insets(2, 2, 2, 2);
    constraints_l.fill = GridBagConstraints.HORIZONTAL;
    constraints_r.fill = GridBagConstraints.BOTH;
    constraints_r.gridx = 1;
    constraints_l.weightx = constraints_r.weightx = 1.0;
    constraints_l.gridy = ++constraints_r.gridy;
    add(new JLabel("World name"), constraints_l);
    add(textfield_name = new JTextField(world.getName()), constraints_r);
    textfield_name.setColumns(20);
    constraints_l.gridy = ++constraints_r.gridy;
    constraints.gridy = constraints_l.gridy = ++constraints_r.gridy;
    constraints.gridwidth = 2;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    add(new JSeparator(), constraints);
    constraints.gridy = constraints_l.gridy = ++constraints_r.gridy;
    add(new JLabel("Risk Levels"), constraints);
    risklevel_colors = new HashMap<>();
    for (RiskLevel rl : world.getRiskLevels()) {
        constraints_l.gridy = ++constraints_r.gridy;
        JTextField tf_rl_name = new JTextField(rl.getDescription());
        add(tf_rl_name, constraints_l);
        ColorChooserButton colorchooser = new ColorChooserButton(getParent(), rl.getColor());
        add(colorchooser, constraints_r);
        risklevel_colors.put(rl, new Pair<>(tf_rl_name, colorchooser));
    }
    constraints_l.gridy = ++constraints_r.gridy;
    add(risklevel_new_name = new JTextField(), constraints_l);
    add(risklevel_new_color = new ColorChooserButton(getParent()), constraints_r);
    constraints_l.gridy = ++constraints_r.gridy;
    add(new JLabel("Tile center color"), constraints_l);
    add(tile_center_color = new ColorChooserButton(getParent(), world.getTileCenterColor()), constraints_r);
    constraints.gridy = constraints_l.gridy = ++constraints_r.gridy;
    add(new JSeparator(), constraints);
    buttongroup_place_id = new ButtonGroup();
    radiobutton_place_id_none = new JRadioButton("Don't show place ID on map");
    radiobutton_place_id_unique = new JRadioButton("Show place ID if name isn't unique");
    radiobutton_place_id_all = new JRadioButton("Always show place ID");
    buttongroup_place_id.add(radiobutton_place_id_none);
    buttongroup_place_id.add(radiobutton_place_id_unique);
    buttongroup_place_id.add(radiobutton_place_id_all);
    constraints_l.gridy = ++constraints_r.gridy;
    add(radiobutton_place_id_none, constraints_l);
    /*constraints_l.gridy = ++constraints_r.gridy; // feature (temporarily?) removed
        add(radiobutton_place_id_unique, constraints_l);*/
    constraints_l.gridy = ++constraints_r.gridy;
    add(radiobutton_place_id_all, constraints_l);
    switch(world.getShowPlaceId()) {
        case NONE:
            buttongroup_place_id.setSelected(radiobutton_place_id_none.getModel(), true);
            break;
        default:
        case UNIQUE:
            buttongroup_place_id.setSelected(radiobutton_place_id_unique.getModel(), true);
            break;
        case ALL:
            buttongroup_place_id.setSelected(radiobutton_place_id_all.getModel(), true);
            break;
    }
    constraints_l.insets = constraints_r.insets = new Insets(0, 2, 0, 2);
    constraints_l.gridy = ++constraints_r.gridy;
    JButton button_cancel = new JButton("Cancel");
    add(button_cancel, constraints_l);
    button_cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            dispose();
        }
    });
    JButton button_ok = new JButton("Ok");
    add(button_ok, constraints_r);
    getRootPane().setDefaultButton(button_ok);
    button_ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            try {
                save();
            } catch (Exception ex) {
                Logger.getLogger(EditWorldDialog.class.getName()).log(Level.SEVERE, null, ex);
            }
            dispose();
        }
    });
    pack();
    setResizable(false);
    setLocation(getParent().getX() + (getParent().getWidth() - getWidth()) / 2, getParent().getY() + (getParent().getHeight() - getHeight()) / 2);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) ActionListener(java.awt.event.ActionListener) ColorChooserButton(mudmap2.frontend.GUIElement.ColorChooserButton) ButtonGroup(javax.swing.ButtonGroup) RiskLevel(mudmap2.backend.RiskLevel)

Aggregations

Pair (mudmap2.utils.Pair)7 Place (mudmap2.backend.Place)4 Map (java.util.Map)3 Color (java.awt.Color)2 GradientPaint (java.awt.GradientPaint)2 Graphics (java.awt.Graphics)2 Graphics2D (java.awt.Graphics2D)2 BufferedImage (java.awt.image.BufferedImage)2 HashMap (java.util.HashMap)2 Layer (mudmap2.backend.Layer)2 RiskLevel (mudmap2.backend.RiskLevel)2 WorldCoordinate (mudmap2.backend.WorldCoordinate)2 Pair (io.fabric8.utils.Pair)1 BasicStroke (java.awt.BasicStroke)1 Dimension (java.awt.Dimension)1 FontMetrics (java.awt.FontMetrics)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1