Changeset 289


Ignore:
Timestamp:
09/03/08 09:50:37 (16 years ago)
Author:
ra33
Message:

Added HTML styles

Location:
trunk/src/org/expeditee
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/agents/DisplayComet.java

    r154 r289  
    2222                super();
    2323        }
    24        
     24
    2525        @Override
    2626        protected Frame process(Frame frame) {
    2727                Collection<String> seen = new HashSet<String>();
    28                
     28
    2929                DisplayIO.addToBack(frame);
    30                
     30
    3131                // Goto the end of the comet
    3232                Item old = null;
    3333                Frame oldFrame = frame;
    3434                while (oldFrame != null) {
    35                         if(_stop)
     35                        if (_stop)
    3636                                return null;
    3737                        seen.add(oldFrame.getName().toLowerCase());
     
    4242                        if (old != null) {
    4343                                String link = old.getAbsoluteLink();
    44                                 String linkLowerCase = link.toLowerCase();
    45                                 if (link != null && !seen.contains(linkLowerCase)) {
    46                                         oldFrame = FrameIO.LoadFrame(linkLowerCase);
    47                                         MessageBay.overwriteMessage("Loading frames: " + link);
     44
     45                                if (link != null) {
     46                                        String linkLowerCase = link.toLowerCase();
     47                                        if (!seen.contains(linkLowerCase)) {
     48                                                oldFrame = FrameIO.LoadFrame(linkLowerCase);
     49                                                MessageBay.overwriteMessage("Loading frames: " + link);
     50                                        }
    4851                                }
    4952                        }
     
    5154                // Back out one frame at a time
    5255                while (!_frameList.empty()) {
    53                         if(_stop)
     56                        if (_stop)
    5457                                return null;
    5558                        DisplayIO.setCurrentFrame(_frameList.pop(), true);
  • trunk/src/org/expeditee/gui/FrameKeyboardActions.java

    r286 r289  
    2020
    2121import org.expeditee.actions.Actions;
     22import org.expeditee.actions.Misc;
    2223import org.expeditee.actions.NavigationActions;
    2324import org.expeditee.actions.Simple;
     
    969970                // get whatever the user is pointing at
    970971                Item on = FrameUtils.getCurrentItem();
    971 
     972                String displayMessage = "F" + key.ordinal() + ": " + key.toString();
    972973                // check for enclosed mode
    973974                if (on == null && key.ordinal() < FunctionKey.AudienceMode.ordinal()) {
     
    10331034                                        AddDate(firstConnected);
    10341035                                        break;
    1035                                 }
    1036                                 return;
    1037                         }
    1038                 }
    1039                 String displayMessage = "F" + key.ordinal() + ": " + key.toString();
     1036                                case Save:
     1037                                        Save();
     1038                                        MessageBay.displayMessage(displayMessage);
     1039                                        break;
     1040                                }
     1041                                return;
     1042                        }
     1043                }
    10401044                // Show a description of the function key pressed if the user is in free
    10411045                // space and return for the F keys that dont do anything in free space.
     
    10481052                        case AudienceMode:
    10491053                        case Refresh:
     1054                        case Save:
    10501055                                break;
     1056                        case SizeDown:
     1057                                if(isControlDown){
     1058                                        UserSettings.ScaleFactor -= 0.05;
     1059                                        Misc.repaint();
     1060                                        return;
     1061                                }
     1062                        case SizeUp:
     1063                                if(isControlDown){
     1064                                        UserSettings.ScaleFactor += 0.05;
     1065                                        Misc.repaint();
     1066                                        return;
     1067                                }
    10511068                        default:
    10521069                                MessageBay.displayMessageOnce(displayMessage);
     
    11031120                        Refresh();
    11041121                        break;
     1122                case Save:
     1123                        Save();
     1124                        break;
    11051125                }
    11061126                on = FrameUtils.getCurrentItem();
     
    11081128                if (on == null && (enclosed == null || enclosed.size() == 0))
    11091129                        MessageBay.displayMessage(displayMessage);
     1130        }
     1131
     1132        private static void Save() {
     1133                Frame current = DisplayIO.getCurrentFrame();
     1134                current.change();
     1135                FrameIO.SaveFrame(current,true, true);
    11101136        }
    11111137
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r286 r289  
    3434import org.expeditee.network.PeerToPeer;
    3535import org.expeditee.stats.SessionStats;
     36import org.jfree.util.ArrayUtilities;
    3637
    3738public class FrameUtils {
     
    637638                        } else if (attribute.equals("framesetdirs")) {
    638639                                UserSettings.FrameDirs.addAll(getDirs(item));
     640                        } else if (attribute.equals("style")) {
     641                                UserSettings.Style = getStyle(item.getChild());
    639642                        } else {
    640643                                errors.add(attributeFullCase + " is not a profile frame tag");
     
    642645                }
    643646                return errors;
     647        }
     648
     649        private static List<Text> getStyle(Frame child) {
     650                List<Text> style = new ArrayList<Text>(8);
     651                for (int i  = 0; i < 10; i++){
     652                        style.add(null);
     653                }
     654
     655                for (Text text : child.getBodyTextItems(false)) {
     656                        String type = text.getText();
     657                        char lastChar = type.charAt(type.length() - 1);
     658                        if (Character.isDigit(lastChar)) {
     659                                style.set(lastChar - '0', text);
     660                        } else {
     661                                style.set(0, text);
     662                        }
     663                }
     664                return style;
    644665        }
    645666
  • trunk/src/org/expeditee/gui/FunctionKey.java

    r80 r289  
    44public enum FunctionKey {
    55        DropDown, SizeUp, SizeDown, ChangeColor, ToggleAnnotation, InsertDate, NewFrameset, ChangeFontStyle, ChangeFontFamily,
    6         AudienceMode, XRayMode, Unused, Refresh;
     6        AudienceMode, XRayMode, Save, Refresh;
    77}
  • trunk/src/org/expeditee/gui/UserSettings.java

    r286 r289  
    33import java.io.File;
    44import java.net.URL;
     5import java.util.Collection;
    56import java.util.LinkedList;
    67import java.util.List;
     
    1516public abstract class UserSettings {
    1617
     18        public static List<Text> Style;
     19       
    1720        public static int Gravity = 3;
     21       
     22        public static float ScaleFactor = 1F;
    1823
    1924        public static int LineStraightenThreshold = 15;
     
    8590         * runs the jar from the command line from another directory.
    8691         *
    87          * @return
     92         * @return the full path location of the Jar
    8893         */
    8994        public static String getJarLocation() {
  • trunk/src/org/expeditee/io/AbstractHTMLWriter.java

    r121 r289  
    11package org.expeditee.io;
    22
     3import java.awt.Color;
     4import java.awt.Font;
    35import java.io.File;
    46import java.io.IOException;
     7import java.util.List;
    58
    69import org.expeditee.gui.Frame;
    710import org.expeditee.gui.MessageBay;
    8 import org.expeditee.items.Item;
     11import org.expeditee.gui.UserSettings;
     12import org.expeditee.items.Text;
    913
    1014public abstract class AbstractHTMLWriter extends DefaultTreeWriter {
    11         private int _indent = 0;
    1215
    1316        private static final String INDENT = "   ";
     
    2427                _writer.write("<title>" + start.getTitle());
    2528                _writer.write("</title>" + ItemWriter.NEW_LINE);
     29
     30                // Write in the style for the headers and body text
     31                _writer.write("<style>" + ItemWriter.NEW_LINE);
     32                _writer.write("<!--" + ItemWriter.NEW_LINE);
     33
     34                // Go through all the styles
     35                List<Text> style = UserSettings.Style;
     36
     37                writeStyleInfo(_writer, "P", style.get(0));
     38                for (int i = 1; i < style.size(); i++) {
     39                        writeStyleInfo(_writer, "H" + i, style.get(i));
     40                }
     41                _writer.write("-->" + ItemWriter.NEW_LINE);
     42                _writer.write("</style>" + ItemWriter.NEW_LINE);
     43
    2644                _writer.write("</head>" + ItemWriter.NEW_LINE);
    2745                _writer.write("<body>" + ItemWriter.NEW_LINE);
     46        }
     47
     48        private void writeStyleInfo(ProxyWriter writer, String styleName, Text style)
     49                        throws IOException {
     50                if (style == null)
     51                        return;
     52
     53                writer.write(styleName + " { font-size: " + Math.round(style.getSize())
     54                                + "pt");
     55
     56                Font font = style.getPaintFont();
     57                if(font == null)
     58                        return;
     59               
     60                writer.write("; font-family: " + Conversion.getCssFontFamily(font.getFamily()));
     61                if (font.isBold()) {
     62                        writer.write("; font-weight: bold");
     63                } else {
     64                        writer.write("; font-weight: normal");
     65                }
     66
     67                if (font.isItalic()) {
     68                        writer.write("; font-style: italic");
     69                } else {
     70                        writer.write("; font-style: normal");
     71                }
     72                Color c = style.getBackgroundColor();
     73                if (c != null) {
     74                        writer.write("; background-color: " + Conversion.getCssColor(c));
     75                }
     76                c = style.getColor();
     77                if (c != null) {
     78                        writer.write("; color: " + Conversion.getCssColor(c));
     79                }
     80               
     81                c = style.getBorderColor();
     82                if (c != null) {
     83                        writer.write("; outline-color: " + Conversion.getCssColor(c));
     84                        writer.write("; outline-style: solid");
     85                }
     86               
     87                writer.write("}" + ItemWriter.NEW_LINE);
     88
    2889        }
    2990
     
    3293        protected String getFilesFolder() {
    3394                if (_filesFolderName == null) {
    34                         _filesFolderName = _filename.substring(0, _filename.lastIndexOf('.')) + FILE_FOLDER_SUFFIX;
    35                         File dir = new File (_filesFolderName);
     95                        _filesFolderName = _filename.substring(0, _filename
     96                                        .lastIndexOf('.'))
     97                                        + FILE_FOLDER_SUFFIX;
     98                        File dir = new File(_filesFolderName);
    3699                        _filesFolderName = dir.getName();
    37100                        if (!dir.exists()) {
     
    46109                        }
    47110                }
    48                
     111
    49112                return _filesFolderName + File.separator;
    50113        }
     
    54117                _writer.write("</body>" + ItemWriter.NEW_LINE);
    55118                return super.finaliseTree();
    56         }
    57 
    58         @Override
    59         protected void writeStartLink(Item linker) throws IOException {
    60                 _indent++;
    61         }
    62 
    63         @Override
    64         protected void writeEndLink(Item linker) throws IOException {
    65                 _indent--;
    66119        }
    67120
  • trunk/src/org/expeditee/io/Conversion.java

    r226 r289  
    219219                String code = Text.FONT_WHEEL[0];
    220220                if (separator > 0) {
    221                         code = Actions.getCapitalizedFontName(fontCode.substring(0,separator)) + '-';
     221                        code = Actions.getCapitalizedFontName(fontCode.substring(0,
     222                                        separator)) + '-';
    222223                        fontCode = fontCode.substring(separator);
    223224                } else {
     
    385386                        return Float.parseFloat(value);
    386387                }
    387                
     388
    388389                if (type.equals(Float.class)) {
    389390                        if (orig instanceof Float
     
    393394                                return ((Float) orig) + Float.parseFloat(value);
    394395                        }
    395                        
    396                         if (value.length() == 0 ||  value.equals("null"))
     396
     397                        if (value.length() == 0 || value.equals("null"))
    397398                                return null;
    398 
    399399
    400400                        return Float.parseFloat(value);
     
    491491                        just[0] = Justification.getJustification(value);
    492492                        return just;
    493                 }else if (name.endsWith("Permission")) {
     493                } else if (name.endsWith("Permission")) {
    494494                        Permission[] permission = new Permission[1];
    495495                        permission[0] = Permission.getPermission(value);
     
    560560                        return output;
    561561
    562                 if(name.endsWith("Text")){
     562                if (name.endsWith("Text")) {
    563563                        List<String> list = new LinkedList<String>();
    564                         for(String s: output.toString().split("\n")){
     564                        for (String s : output.toString().split("\n")) {
    565565                                list.add(s);
    566566                        }
     
    569569                if (name.endsWith("Justification"))
    570570                        return ((Justification) output).getCode();
    571                
     571
    572572                if (name.endsWith("Permission"))
    573573                        return ((Permission) output).getCode();
     
    619619        public static String getPdfFont(String family) {
    620620                family = family.toLowerCase();
    621                 if(family.equals(Text.FONT_WHEEL[0])){
     621                if (family.equals(Text.FONT_WHEEL[0])) {
    622622                        return FontFactory.HELVETICA;
    623                 }else if(family.equals(Text.FONT_WHEEL[2])){
     623                } else if (family.equals(Text.FONT_WHEEL[2])) {
    624624                        return FontFactory.TIMES_ROMAN;
    625625                }
    626626                return FontFactory.COURIER;
    627627        }
     628
     629        public static String getCssColor(Color c) {
     630                assert (c != null);
     631                return "rgb(" + c.getRed() + "," + c.getGreen() + "," + c.getBlue()
     632                                + ")";
     633        }
     634
     635        public static String getCssFontFamily(String family) {
     636                family = family.toLowerCase();
     637                if(family.equals("monospaced") || family.equals("dialog")){
     638                        return "courier";
     639                }else if(family.equals("sansserif")){
     640                        return "sans-serif";
     641                }else{
     642                        return family;
     643                }
     644        }
    628645}
  • trunk/src/org/expeditee/io/DefaultTreeWriter.java

    r121 r289  
    1414                TreeWriter {
    1515
     16        protected int _indent = 0;
     17       
    1618        // the list of frames currently being processed
    1719        private Stack<FrameCounter> _frames = new Stack<FrameCounter>();
     
    4749         */
    4850        protected void writeStartLink(Item linker) throws IOException {
    49 
     51                _indent++;
    5052        }
    5153
     
    5961         */
    6062        protected void writeEndLink(Item linker) throws IOException {
    61 
     63                _indent--;
    6264        }
    6365
  • trunk/src/org/expeditee/items/Item.java

    r286 r289  
    3535import org.expeditee.gui.MessageBay;
    3636import org.expeditee.gui.Overlay;
     37import org.expeditee.gui.UserSettings;
    3738import org.expeditee.gui.Vector;
    3839import org.expeditee.io.Conversion;
     
    192193                dest._overlay = source._overlay;
    193194                dest._mode = source._mode;// SelectedMode.None;
    194                 //dest._highlightColor = source._highlightColor;
    195                 //dest.setHighlight(source.getHighlight());
    196                
     195                // dest._highlightColor = source._highlightColor;
     196                // dest.setHighlight(source.getHighlight());
     197
    197198                dest._visible = source._visible;
    198199                Frame parent = source.getParentOrCurrentFrame();
  • trunk/src/org/expeditee/items/Text.java

    r286 r289  
    3636import org.expeditee.gui.FrameMouseActions;
    3737import org.expeditee.gui.FrameUtils;
     38import org.expeditee.gui.UserSettings;
    3839import org.expeditee.math.ExpediteeJEP;
    3940import org.nfunk.jep.Node;
     
    275276
    276277        public void setAttributeValue(String value) {
    277                 AttributeValuePair avp = new AttributeValuePair(getText(),false);
     278                AttributeValuePair avp = new AttributeValuePair(getText(), false);
    278279                avp.setValue(value);
    279280                setText(avp.toString());
     
    14261427                if (hasFormula()) {
    14271428                        g.setColor(getPaintHighlightColor());
    1428                         Stroke highlightStroke = new BasicStroke(
    1429                                         1F, CAP, JOIN);
     1429                        Stroke highlightStroke = new BasicStroke(1F, CAP, JOIN);
    14301430                        g.setStroke(highlightStroke);
    14311431
     
    15561556        public void setSize(float size) {
    15571557                invalidateAll();
     1558                //size *= UserSettings.ScaleFactor;
    15581559                // Dont want to have size set when duplicating a point which has size 0
    15591560                if (size < 0)
Note: See TracChangeset for help on using the changeset viewer.