Ignore:
Timestamp:
2013-04-23T13:12:05+02:00 (12 years ago)
Author:
donvip
Message:

[josm_print] fix unauthorized operations + warnings

Location:
applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print/PrintAction.java

    r28367 r29529  
    7070        public void run () {
    7171        PrintPlugin.adjustPrefs();
    72         PrintDialog window = new PrintDialog(Main.main.parent);
     72        PrintDialog window = new PrintDialog(Main.parent);
    7373        window.setVisible(true);
    7474        PrintPlugin.restorePrefs();
  • applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print/PrintDialog.java

    r27316 r29529  
    2828import java.awt.Component;
    2929import java.awt.Dimension;
    30 import java.awt.GridBagConstraints;
    3130import java.awt.GridBagLayout;
    3231import java.awt.Insets;
     
    3433import java.awt.event.ActionEvent;
    3534import java.awt.event.ActionListener;
    36 import java.awt.print.*;
    37 
     35import java.awt.print.PageFormat;
     36import java.awt.print.PrinterAbortException;
     37import java.awt.print.PrinterException;
     38import java.awt.print.PrinterJob;
    3839import java.text.ParseException;
    3940
    40 import javax.print.*;
    41 import javax.print.attribute.*;
    42 import javax.print.attribute.standard.*;
     41import javax.print.PrintService;
     42import javax.print.PrintServiceLookup;
     43import javax.print.attribute.Attribute;
     44import javax.print.attribute.HashPrintRequestAttributeSet;
     45import javax.print.attribute.PrintRequestAttributeSet;
     46import javax.print.attribute.standard.Media;
     47import javax.print.attribute.standard.MediaPrintableArea;
     48import javax.print.attribute.standard.OrientationRequested;
    4349import javax.swing.JButton;
    4450import javax.swing.JCheckBox;
     
    331337        }
    332338        JScrollPane previewPane = new JScrollPane(printPreview, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    333         previewPane.setPreferredSize(Main.main != null ? Main.main.map.mapView.getSize() : new Dimension(210,297));
     339        previewPane.setPreferredSize(Main.main != null ? Main.map.mapView.getSize() : new Dimension(210,297));
    334340        add(previewPane, GBC.std(0,0).span(1, GBC.RELATIVE).fill().weight(5.0,5.0));
    335341
     
    394400        String cmd = e.getActionCommand();
    395401        if (cmd.equals("printer-dialog")) {
    396             PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
    397             PrintService svc = PrintServiceLookup.lookupDefaultPrintService();
     402            /*PrintService[] services =*/ PrintServiceLookup.lookupPrintServices(null, null);
     403            /*PrintService svc =*/ PrintServiceLookup.lookupDefaultPrintService();
    398404            if (job.printDialog(attrs)) {
    399405                updateFields();
     
    430436                    msg = tr("Printing has been cancelled.");
    431437                }
    432                 JOptionPane.showMessageDialog(Main.main.parent, msg,
     438                JOptionPane.showMessageDialog(Main.parent, msg,
    433439                  tr("Printing stopped"),
    434440                  JOptionPane.WARNING_MESSAGE);
     
    439445                    msg = tr("Printing has failed.");
    440446                }
    441                 JOptionPane.showMessageDialog(Main.main.parent, msg,
     447                JOptionPane.showMessageDialog(Main.parent, msg,
    442448                  tr("Printing stopped"),
    443449                  JOptionPane.ERROR_MESSAGE);
  • applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print/PrintPlugin.java

    r27760 r29529  
    2323
    2424package org.openstreetmap.josm.plugins.print;
    25 
    26 import java.awt.Toolkit;
    2725
    2826import javax.swing.JMenu;
  • applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print/PrintableMapView.java

    r29210 r29529  
    3333import java.awt.Graphics;
    3434import java.awt.Graphics2D;
    35 import java.awt.Image;
    3635import java.awt.Shape;
    37 import java.awt.event.ActionEvent;
    38 import java.awt.event.KeyEvent;
    3936import java.awt.font.FontRenderContext;
    4037import java.awt.font.GlyphVector;
    4138import java.awt.geom.AffineTransform;
    4239import java.awt.geom.Rectangle2D;
    43 import java.awt.print.*;
     40import java.awt.print.PageFormat;
     41import java.awt.print.Printable;
     42import java.awt.print.PrinterException;
    4443import java.util.ArrayList;
    4544import java.util.Collections;
     
    5251import org.openstreetmap.josm.data.Bounds;
    5352import org.openstreetmap.josm.gui.MapView;
    54 import org.openstreetmap.josm.gui.NavigatableComponent.SystemOfMeasurement;
    5553import org.openstreetmap.josm.gui.layer.Layer;
    5654import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    9896        }
    9997       
    100         mapView = Main.main.map.mapView;
     98        mapView = Main.map.mapView;
    10199    }
    102100
     
    232230        List<Layer> visibleLayers = getVisibleLayersInZOrder();
    233231        for (Layer l : visibleLayers) {
    234             try {
    235                 if (! (l instanceof OsmDataLayer)) {
    236                     /* OsmDataLayer does not need this.*/
    237                    
    238                     /* This manipulations may have all kinds of unwanted side effects
    239                      * but many Layer implementations heavily depend on Main.map.mapView. */
    240                     Main.map.mapView = this;
    241                 }
    242                 if (l.getOpacity() < 1) {
    243                     g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,(float)l.getOpacity()));
    244                 }
    245                 l.paint(g2d, this, box);
    246                 g2d.setPaintMode();
     232            if (l.getOpacity() < 1) {
     233                g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,(float)l.getOpacity()));
    247234            }
    248             finally {
    249                 Main.map.mapView = mapView;
    250             }
     235            l.paint(g2d, this, box);
     236            g2d.setPaintMode();
    251237        }
    252238
     
    267253        double dist100px = getDist100Pixel() / g2dFactor;
    268254        double dist = dist100px / som.aValue;
    269         String unit  = som.aName;
     255        //String unit  = som.aName;
    270256        if (!Main.pref.getBoolean("system_of_measurement.use_only_lower_unit", false) && dist > som.bValue / som.aValue) {
    271257            dist = dist100px / som.bValue;
    272             unit  = som.bName;
     258            //unit  = som.bName;
    273259        }
    274260        long distExponent = (long) Math.floor(Math.log(dist) / Math.log(10));
Note: See TracChangeset for help on using the changeset viewer.