Author: kmorin Date: 2014-05-20 23:03:58 +0200 (Tue, 20 May 2014) New Revision: 83 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/83 Log: fixes #5112 Permettre le surlignement Added: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorHighlighterUI.css trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorHighlighterUI.jaxx trunk/faxtomail-ui-swing/src/main/resources/icons/action-highlighter.png Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.css trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.jaxx trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties trunk/faxtomail-ui-swing/src/main/resources/icons/action-line.png Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-05-20 14:25:32 UTC (rev 82) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-05-20 21:03:58 UTC (rev 83) @@ -41,6 +41,7 @@ import com.franciaflex.faxtomail.persistence.entities.AttachmentFile; import com.franciaflex.faxtomail.ui.swing.content.attachment.AttachmentEditorUI; import com.franciaflex.faxtomail.ui.swing.content.pdfeditor.PDFEditorCrossUI; +import com.franciaflex.faxtomail.ui.swing.content.pdfeditor.PDFEditorHighlighterUI; import com.franciaflex.faxtomail.ui.swing.content.pdfeditor.PDFEditorLineUI; import com.franciaflex.faxtomail.ui.swing.content.pdfeditor.PDFEditorNoteUI; import com.franciaflex.faxtomail.ui.swing.content.pdfeditor.PDFEditorUI; @@ -56,6 +57,7 @@ import com.itextpdf.text.pdf.PdfAction; import com.itextpdf.text.pdf.PdfContentByte; import com.itextpdf.text.pdf.PdfDictionary; +import com.itextpdf.text.pdf.PdfGState; import com.itextpdf.text.pdf.PdfName; import com.itextpdf.text.pdf.PdfNumber; import com.itextpdf.text.pdf.PdfReader; @@ -212,6 +214,25 @@ cb.stroke(); cb.restoreState(); } + + for (PDFEditorHighlighterUI panel : model.getPages()[i].getHighlighters()) { + + Point location = panel.getLocation(); + int width = (int) (panel.getWidth() / zoom); + int height = (int) (panel.getHeight() / zoom); + int x = (int) (location.x / zoom); + int y = (int) ((getUI().getContainer().getHeight() - location.y) / zoom) - height; + + cb.saveState(); + PdfGState gs1 = new PdfGState(); + gs1.setFillOpacity(0.4f); + cb.setGState(gs1); + + cb.setColorFill(BaseColor.YELLOW); + cb.rectangle(x, y, width, height); + cb.fill(); + cb.restoreState(); + } } pdfStamper.close(); Copied: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorHighlighterUI.css (from rev 81, trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorCrossUI.css) =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorHighlighterUI.css (rev 0) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorHighlighterUI.css 2014-05-20 21:03:58 UTC (rev 83) @@ -0,0 +1,37 @@ +/* + * #%L + * FaxToMail :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * This program 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 3 of the + * License, or (at your option) any later version. + * + * This program 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +#highlighterPanel { + //scaleImageToFitPanel: { true }; + border: { BorderFactory.createDashedBorder(null) }; + background: { new Color(255, 255, 0, 100) }; + size: { new Dimension(500, 200) }; +} + +#removeButton { + text: "X"; + //borderPainted: { false }; + //border: { null }; + //opaque : { false }; + //background: { null }; +} \ No newline at end of file Copied: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorHighlighterUI.jaxx (from rev 81, trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorCrossUI.jaxx) =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorHighlighterUI.jaxx (rev 0) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorHighlighterUI.jaxx 2014-05-20 21:03:58 UTC (rev 83) @@ -0,0 +1,51 @@ +<!-- + #%L + FaxToMail :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2014 Franciaflex, Code Lutin + %% + This program 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 3 of the + License, or (at your option) any later version. + + This program 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='highlighterPanel' layout='{new FlowLayout(FlowLayout.TRAILING)}'> + + <import> + java.awt.BasicStroke + java.awt.Color + java.awt.Dimension + java.awt.FlowLayout + java.awt.Font + java.awt.Graphics + java.awt.Graphics2D + javax.swing.BorderFactory + javax.swing.JPanel + </import> + + <script><![CDATA[ + + protected void removeCross() { + JPanel container = getParentContainer(JPanel.class); + container.remove(this); + container.updateUI(); + } + + ]]></script> + + <JButton id="removeButton" + onActionPerformed="removeCross()"/> + +</JPanel> \ No newline at end of file Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.css =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.css 2014-05-20 14:25:32 UTC (rev 82) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.css 2014-05-20 21:03:58 UTC (rev 83) @@ -46,6 +46,11 @@ toolTipText: "faxtomail.pdfEditor.button.addLine.tip"; } +#highlighterButton { + actionIcon: highlighter; + toolTipText: "faxtomail.pdfEditor.button.addHighlighter.tip"; +} + #prevPageButton { actionIcon: left; enabled: { getModel().getCurrentPageIndex() > 1 }; Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.jaxx 2014-05-20 14:25:32 UTC (rev 82) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.jaxx 2014-05-20 21:03:58 UTC (rev 83) @@ -55,6 +55,8 @@ onActionPerformed="handler.addCross()"/> <JButton id='lineButton' onActionPerformed="handler.addLine()"/> + <JButton id='highlighterButton' + onActionPerformed="handler.addHighlighter()"/> <JSeparator constructorParams="SwingConstants.VERTICAL"/> Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java 2014-05-20 14:25:32 UTC (rev 82) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java 2014-05-20 21:03:58 UTC (rev 83) @@ -114,6 +114,9 @@ } else if (child.getClass().isAssignableFrom(PDFEditorLineUI.class)) { currentPage.addLine((PDFEditorLineUI) child); + + } else if (child.getClass().isAssignableFrom(PDFEditorHighlighterUI.class)) { + currentPage.addHighlighter((PDFEditorHighlighterUI) child); } } @@ -129,6 +132,9 @@ } else if (child.getClass().isAssignableFrom(PDFEditorLineUI.class)) { currentPage.removeLine((PDFEditorLineUI) child); + + } else if (child.getClass().isAssignableFrom(PDFEditorHighlighterUI.class)) { + currentPage.removeHighlighter((PDFEditorHighlighterUI) child); } } }); @@ -249,6 +255,12 @@ cr.registerComponent(ComponentResizer.DIRECTION_HORIZONTAL, line); } + public void addHighlighter() { + PDFEditorHighlighterUI highlighter = new PDFEditorHighlighterUI(); + addPanel(highlighter); + cr.registerComponent(highlighter); + } + protected void addPanel(JPanel panel) { JPanel container = ui.getContainer(); container.add(panel, 0); @@ -415,6 +427,35 @@ panel); } + for (PDFEditorHighlighterUI panel : p.getHighlighters()) { + panel.setVisible(true); + + Rectangle bounds = panel.getBounds(); + + int newWidth = orientation180 ? bounds.width : bounds.height; + int newHeight = orientation180 ? bounds.height : bounds.width; + + int x, y; + + if (rotationDiff == 0) { + x = bounds.x; + y = bounds.y; + + } else if (rotationDiff == 90 || rotationDiff == -270) { + x = rect.width - newWidth - bounds.y; + y = bounds.x; + + } else { + x = bounds.y; + y = rect.height - newHeight - bounds.x; + } + + panel.setBounds((int) (zoomRatio * x) + insets.left, + (int) (zoomRatio * y) + insets.top, + (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight)); + + } + container.updateUI(); } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java 2014-05-20 14:25:32 UTC (rev 82) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java 2014-05-20 21:03:58 UTC (rev 83) @@ -56,6 +56,7 @@ protected List<PDFEditorNoteUI> notes = new ArrayList<PDFEditorNoteUI>(); protected List<PDFEditorCrossUI> crosses = new ArrayList<PDFEditorCrossUI>(); protected List<PDFEditorLineUI> lines = new ArrayList<PDFEditorLineUI>(); + protected List<PDFEditorHighlighterUI> highlighters = new ArrayList<PDFEditorHighlighterUI>(); public List<PDFEditorNoteUI> getNotes() { return notes; @@ -92,6 +93,18 @@ public void removeLine(PDFEditorLineUI line) { lines.remove(line); } + + public List<PDFEditorHighlighterUI> getHighlighters() { + return highlighters; + } + + public void addHighlighter(PDFEditorHighlighterUI highlighter) { + highlighters.add(highlighter); + } + + public void removeHighlighter(PDFEditorHighlighterUI highlighter) { + highlighters.remove(highlighter); + } } protected Page[] pages; Modified: trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties =================================================================== --- trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties 2014-05-20 14:25:32 UTC (rev 82) +++ trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties 2014-05-20 21:03:58 UTC (rev 83) @@ -200,6 +200,7 @@ faxtomail.pdfEditor.action.validate=Enregistrer faxtomail.pdfEditor.action.validate.tip=Enregistrer les changements et fermer faxtomail.pdfEditor.button.addCross.tip=Ajouter une croix +faxtomail.pdfEditor.button.addHighlighter.tip=Ajouter un surlignement faxtomail.pdfEditor.button.addLine.tip=Ajouter une ligne faxtomail.pdfEditor.button.addNote.tip=Ajouter une note faxtomail.pdfEditor.button.nextPage=Page suivante Added: trunk/faxtomail-ui-swing/src/main/resources/icons/action-highlighter.png =================================================================== (Binary files differ) Property changes on: trunk/faxtomail-ui-swing/src/main/resources/icons/action-highlighter.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/faxtomail-ui-swing/src/main/resources/icons/action-line.png =================================================================== (Binary files differ)