[tiled] r654 - in trunk: . plugins/mappy/src/tiled/plugins/mappy plugins/tmw/src/tiled/plugins/tmw src/tiled/io src/tiled/mapeditor/dialogs src/tiled/mapeditor/widget src/tiled/view

svn@biggeruniverse.com svn at biggeruniverse.com
Fri Jun 2 05:52:13 PDT 2006


Author: bjorn
Date: 2006-06-02 07:52:12 -0500 (Fri, 02 Jun 2006)
New Revision: 654

Modified:
   trunk/CHANGES
   trunk/plugins/mappy/src/tiled/plugins/mappy/MappyMapReader.java
   trunk/plugins/mappy/src/tiled/plugins/mappy/MappyMapWriter.java
   trunk/plugins/tmw/src/tiled/plugins/tmw/TMWServerMapWriter.java
   trunk/src/tiled/io/PluggableMapIO.java
   trunk/src/tiled/mapeditor/dialogs/AboutDialog.java
   trunk/src/tiled/mapeditor/widget/TileButton.java
   trunk/src/tiled/view/OrthoMapView.java
Log:
Added memory usage display to about dialog. Also simplified grid drawing a bit for orthogonal view, and eliminated the one extra pixel in preferred size when grid enabled.

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2006-05-30 22:28:58 UTC (rev 653)
+++ trunk/CHANGES	2006-06-02 12:52:12 UTC (rev 654)
@@ -25,6 +25,7 @@
 * Added more useful visual feedback for some brushes
 * Added remembering of main window state as suggested by Dennis Spreen
 * Added remembering of size and divider position to tile palette dialog
+* Added display of memory usage to the about dialog
 * Improved memory usage and speed in several areas
 * Fixed new tileset dialog so that it is now possible to change the tile height
   to something other than the tile height used by the map

Modified: trunk/plugins/mappy/src/tiled/plugins/mappy/MappyMapReader.java
===================================================================
--- trunk/plugins/mappy/src/tiled/plugins/mappy/MappyMapReader.java	2006-05-30 22:28:58 UTC (rev 653)
+++ trunk/plugins/mappy/src/tiled/plugins/mappy/MappyMapReader.java	2006-06-02 12:52:12 UTC (rev 654)
@@ -106,7 +106,7 @@
     }
 
     /**
-     * @see tiled.io.MapReader#getFilter()
+     * @see tiled.io.PluggableMapIO#getFilter()
      */
     public String getFilter() throws Exception {
         return "*.fmp";
@@ -269,7 +269,7 @@
     }
 
     /**
-     * BGFX blocks are synonymous with {@link tiled.core.Tile}s
+     * BGFX blocks are synonymous with {@link Tile}s
      *
      * @param m The Map to add Tiles to
      * @param in

Modified: trunk/plugins/mappy/src/tiled/plugins/mappy/MappyMapWriter.java
===================================================================
--- trunk/plugins/mappy/src/tiled/plugins/mappy/MappyMapWriter.java	2006-05-30 22:28:58 UTC (rev 653)
+++ trunk/plugins/mappy/src/tiled/plugins/mappy/MappyMapWriter.java	2006-06-02 12:52:12 UTC (rev 654)
@@ -15,7 +15,6 @@
 import java.io.*;
 import java.util.Iterator;
 import java.util.LinkedList;
-import java.util.Stack;
 
 import tiled.io.MapWriter;
 import tiled.io.PluginLogger;
@@ -67,7 +66,7 @@
     }
 
     /**
-     * @see tiled.io.MapReader#getFilter()
+     * @see tiled.io.PluggableMapIO#getFilter()
      */
     public String getFilter() throws Exception {
         return "*.map";

Modified: trunk/plugins/tmw/src/tiled/plugins/tmw/TMWServerMapWriter.java
===================================================================
--- trunk/plugins/tmw/src/tiled/plugins/tmw/TMWServerMapWriter.java	2006-05-30 22:28:58 UTC (rev 653)
+++ trunk/plugins/tmw/src/tiled/plugins/tmw/TMWServerMapWriter.java	2006-06-02 12:52:12 UTC (rev 654)
@@ -35,7 +35,7 @@
     private static final int FIRST_BYTE = 0x000000FF;
 
     private PluginLogger logger;
-    
+
     /**
      * Loads a map from a file.
      *
@@ -91,7 +91,7 @@
     }
 
     /**
-     * @see tiled.io.MapReader#getFilter()
+     * @see tiled.io.PluggableMapIO#getFilter()
      */
     public String getFilter() throws Exception {
         return "*.wlk";

Modified: trunk/src/tiled/io/PluggableMapIO.java
===================================================================
--- trunk/src/tiled/io/PluggableMapIO.java	2006-05-30 22:28:58 UTC (rev 653)
+++ trunk/src/tiled/io/PluggableMapIO.java	2006-06-02 12:52:12 UTC (rev 654)
@@ -5,16 +5,13 @@
  *  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.
- * 
+ *
  *  Adam Turk <aturk at biggeruniverse.com>
  *  Bjorn Lindeijer <b.lindeijer at xs4all.nl>
  */
 
 package tiled.io;
 
-import java.util.Stack;
-
-
 /**
  * This is the interface for all Tiled I/O plugins, whether they load, save, or
  * both. The PluginClassLoader also uses this to check the supported file
@@ -25,42 +22,42 @@
     /**
      * Lists supported file extensions. This function is used by the editor to
      * find the plugin to use for a specific file extension.
-     * 
+     *
      * @return a comma delimited string of supported file extensions
      * @throws Exception
      */
     public String getFilter() throws Exception;
 
     /**
-     * Returns a short description of the plugin, or the plugin name. This 
+     * Returns a short description of the plugin, or the plugin name. This
      * string is displayed in the list of loaded plugins under the Help menu in
      * Tiled.
-     * 
-     * @return a short name or description  
+     *
+     * @return a short name or description
      */
     public String getName();
 
     /**
-     * Returns a long description (no limit) that details the plugin's 
+     * Returns a long description (no limit) that details the plugin's
      * capabilities, author, contact info, etc.
-     * 
+     *
      * @return a long description of the plugin
      */
     public String getDescription();
-    
+
     /**
      * Returns the base Java package string for the plugin
-     * 
+     *
      * @return String the base package of the plugin
      */
     public String getPluginPackage();
-    
+
     /**
      * The PluginLogger object passed by the editor when the plugin is called to load
      * or save a map can be used by the plugin to notify the user of any
      * problems or messages.
-     * 
-     * @param logger 
+     *
+     * @param logger
      */
     public void setLogger(PluginLogger logger);
 }

Modified: trunk/src/tiled/mapeditor/dialogs/AboutDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/AboutDialog.java	2006-05-30 22:28:58 UTC (rev 653)
+++ trunk/src/tiled/mapeditor/dialogs/AboutDialog.java	2006-06-02 12:52:12 UTC (rev 654)
@@ -5,18 +5,20 @@
  *  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.
- * 
+ *
  *  Adam Turk <aturk at biggeruniverse.com>
  *  Bjorn Lindeijer <b.lindeijer at xs4all.nl>
  */
 
 package tiled.mapeditor.dialogs;
 
+import java.awt.Component;
+import java.awt.Dimension;
 import java.awt.event.MouseEvent;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.BorderFactory;
-import javax.swing.JDialog;
+import java.util.Timer;
+import java.util.TimerTask;
+import javax.swing.*;
+import javax.swing.border.CompoundBorder;
 import javax.swing.event.MouseInputAdapter;
 
 import tiled.mapeditor.MapEditor;
@@ -30,30 +32,81 @@
 public class AboutDialog extends JDialog
 {
     private final JFrame parent;
+    private JProgressBar memoryBar;
 
     public AboutDialog(JFrame parent) {
         super(parent, Resources.getString("dialog.main.title") + " v" + MapEditor.version);
 
         this.parent = parent;
 
-        JLabel label = new JLabel(Resources.getIcon("logo.png"));
-        label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-        label.addMouseListener(new MouseInputAdapter() {
+        Timer timer = new Timer(true);
+        timer.scheduleAtFixedRate(new UpdateTimerTask(), 0, 1000);
+
+        setContentPane(createMainPanel());
+        setResizable(false);
+        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+        addMouseListener(new MouseInputAdapter() {
             public void mouseClicked(MouseEvent mouseEvent) {
                 setVisible(false);
             }
         });
-
-        setContentPane(label);
-        setResizable(false);
-        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
         pack();
     }
 
+    private JPanel createMainPanel() {
+        JLabel label = new JLabel(Resources.getIcon("logo.png"));
+        label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+        label.setAlignmentX(Component.LEFT_ALIGNMENT);
+
+        JSeparator separator = new JSeparator();
+        separator.setAlignmentX(Component.LEFT_ALIGNMENT);
+
+        memoryBar = new JProgressBar();
+        memoryBar.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5),
+                                               memoryBar.getBorder()));
+        memoryBar.setMaximumSize(new Dimension(label.getPreferredSize().width,
+                                               Short.MAX_VALUE));
+        memoryBar.setAlignmentX(Component.LEFT_ALIGNMENT);
+        memoryBar.setStringPainted(true);
+
+        JPanel mainPanel = new JPanel();
+        mainPanel.setOpaque(false);
+        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
+        mainPanel.add(label);
+        mainPanel.add(separator);
+        mainPanel.add(memoryBar);
+        return mainPanel;
+    }
+
+    private void updateMemoryBar() {
+        int total = (int) Runtime.getRuntime().totalMemory();
+        int used = (int) (total - Runtime.getRuntime().freeMemory());
+        memoryBar.setMaximum(total);
+        memoryBar.setValue(used);
+        memoryBar.setString(used / 1024 + " KB / " + total / 1024 + " KB");
+    }
+
     public void setVisible(boolean visible) {
         if (visible) {
+            updateMemoryBar();
             setLocationRelativeTo(parent);
         }
         super.setVisible(visible);
     }
+
+    /**
+     * Used for updating the memory bar in intervals.
+     */
+    private class UpdateTimerTask extends TimerTask
+    {
+        public void run() {
+            if (isVisible()) {
+                SwingUtilities.invokeLater(new Runnable() {
+                    public void run() {
+                        updateMemoryBar();
+                    }
+                });
+            }
+        }
+    }
 }

Modified: trunk/src/tiled/mapeditor/widget/TileButton.java
===================================================================
--- trunk/src/tiled/mapeditor/widget/TileButton.java	2006-05-30 22:28:58 UTC (rev 653)
+++ trunk/src/tiled/mapeditor/widget/TileButton.java	2006-06-02 12:52:12 UTC (rev 654)
@@ -5,7 +5,7 @@
  *  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.
- * 
+ *
  *  Adam Turk <aturk at biggeruniverse.com>
  *  Bjorn Lindeijer <b.lindeijer at xs4all.nl>
  */
@@ -72,7 +72,7 @@
     }
 
     /*
-     *  Methods for Size Information 
+     * Methods for Size Information.
      */
     /*
     private Dimension calculatePreferredSize( ) {
@@ -90,7 +90,7 @@
     private Dimension calculateInnerSize( ) {
         Insets i = getInsets( );
         int w = getWidth( ) - i.left - i.right;
-        int h = getHeight( ) - i.top - i.bottom; 
+        int h = getHeight( ) - i.top - i.bottom;
         return new Dimension( w, h );
     }
 

Modified: trunk/src/tiled/view/OrthoMapView.java
===================================================================
--- trunk/src/tiled/view/OrthoMapView.java	2006-05-30 22:28:58 UTC (rev 653)
+++ trunk/src/tiled/view/OrthoMapView.java	2006-06-02 12:52:12 UTC (rev 654)
@@ -66,11 +66,10 @@
 
     public Dimension getPreferredSize() {
         Dimension tsize = getTileSize(zoom);
-        int border = showGrid ? 1 : 0;
 
         return new Dimension(
-                map.getWidth() * tsize.width + border,
-                map.getHeight() * tsize.height + border);
+                map.getWidth() * tsize.width,
+                map.getHeight() * tsize.height);
     }
 
     protected void paintLayer(Graphics2D g2d, TileLayer layer, double zoom) {
@@ -132,20 +131,16 @@
 
         // Determine lines to draw from clipping rectangle
         Rectangle clipRect = g2d.getClipBounds();
-        int startX = clipRect.x / tsize.width;
-        int startY = clipRect.y / tsize.height;
-        int endX = (clipRect.x + clipRect.width) / tsize.width + 1;
-        int endY = (clipRect.y + clipRect.height) / tsize.height + 1;
-        int p = startY * tsize.height;
+        int startX = clipRect.x / tsize.width * tsize.width;
+        int startY = clipRect.y / tsize.height * tsize.height;
+        int endX = clipRect.x + clipRect.width;
+        int endY = clipRect.y + clipRect.height;
 
-        for (int y = startY; y < endY; y++) {
-            g2d.drawLine(clipRect.x, p, clipRect.x + clipRect.width - 1, p);
-            p += tsize.height;
+        for (int x = startX; x < endX; x += tsize.width) {
+            g2d.drawLine(x, clipRect.y, x, clipRect.y + clipRect.height - 1);
         }
-        p = startX * tsize.width;
-        for (int x = startX; x < endX; x++) {
-            g2d.drawLine(p, clipRect.y, p, clipRect.y + clipRect.height - 1);
-            p += tsize.width;
+        for (int y = startY; y < endY; y += tsize.height) {
+            g2d.drawLine(clipRect.x, y, clipRect.x + clipRect.width - 1, y);
         }
     }
 




More information about the tiled-commit mailing list