Changeset 171:b5eb1dff5f7c in finroc_plugins_data_types-java


Ignore:
Timestamp:
14.07.2019 23:23:26 (5 weeks ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Tags:
tip
Message:

Adapts to change in rrlib_serialization-java (adds explicit throw clause to binary deserialization functions)

Files:
13 edited

Legend:

Unmodified
Added
Removed
  • Angle.java

    r169 r171  
    5757 
    5858    @Override 
    59     public void deserialize(BinaryInputStream is) { 
     59    public void deserialize(BinaryInputStream is) throws Exception { 
    6060        unsignedRad = is.readDouble(); 
    6161    } 
  • BehaviorStatus.java

    r94 r171  
    6565 
    6666    @Override 
    67     public void deserialize(BinaryInputStream stream) { 
     67    public void deserialize(BinaryInputStream stream) throws Exception { 
    6868        name = stream.readString(); 
    6969        moduleHandle = stream.readInt(); 
  • CameraFeature.java

    r97 r171  
    9595        } 
    9696        @Override 
    97         public void deserialize(BinaryInputStream is) { 
     97        public void deserialize(BinaryInputStream is) throws Exception { 
    9898            available = is.readBoolean(); 
    9999            active = is.readBoolean(); 
     
    115115        } 
    116116        @Override 
    117         public void deserialize(BinaryInputStream is) { 
     117        public void deserialize(BinaryInputStream is) throws Exception { 
    118118            super.deserialize(is); 
    119119            min = is.readFloat(); 
     
    150150 
    151151        @Override 
    152         public void deserialize(BinaryInputStream is) { 
     152        public void deserialize(BinaryInputStream is) throws Exception { 
    153153            name = is.readString(); 
    154154            vendor = is.readString(); 
     
    410410 
    411411    @Override 
    412     public void deserialize(BinaryInputStream is) { 
     412    public void deserialize(BinaryInputStream is) throws Exception { 
    413413        featureId = ID.values()[is.readByte()]; 
    414414        available = is.readBoolean(); 
  • Canvas.java

    r162 r171  
    2222package org.finroc.plugins.data_types; 
    2323 
    24 import java.lang.Math; 
    2524import java.awt.BasicStroke; 
    2625import java.awt.Color; 
     
    169168 
    170169    @Override 
    171     public void deserialize(BinaryInputStream rv) { 
     170    public void deserialize(BinaryInputStream rv) throws Exception { 
    172171        super.deserialize(rv); 
    173172        extractZLevels(); 
     
    177176     * Extract all areas with the same Z-level and store them in zLevels 
    178177     */ 
    179     private void extractZLevels() { 
     178    private void extractZLevels() throws Exception { 
    180179        zLevels.clear(); 
    181180        BinaryInputStream is = tempInputStreamZExtraction; 
     
    305304    @Override 
    306305    public void paint(Graphics2D g, FastBufferedImage imageBuffer) { 
    307         BinaryInputStream is = new BinaryInputStream(this); 
    308         Graphics2D g2d = (g instanceof BoundsExtractingGraphics2D) ? g : (Graphics2D)g.create(); 
    309         AffineTransform defaultTransform = g2d.getTransform(); 
    310  
    311         for (RenderContext lvl : zLevels) { 
    312             if (lvl.commandCount > 0) { 
    313                 is.reset(this); 
    314                 is.skip(lvl.bufferOffset); 
    315                 paintGeometry(g2d, imageBuffer, lvl, is, defaultTransform); 
    316             } 
    317         } 
    318         is.close(); 
     306        try { 
     307            BinaryInputStream is = new BinaryInputStream(this); 
     308            Graphics2D g2d = (g instanceof BoundsExtractingGraphics2D) ? g : (Graphics2D)g.create(); 
     309            AffineTransform defaultTransform = g2d.getTransform(); 
     310 
     311            for (RenderContext lvl : zLevels) { 
     312                if (lvl.commandCount > 0) { 
     313                    is.reset(this); 
     314                    is.skip(lvl.bufferOffset); 
     315                    paintGeometry(g2d, imageBuffer, lvl, is, defaultTransform); 
     316                } 
     317            } 
     318            is.close(); 
     319        } catch (Exception e) { 
     320            Log.log(LogLevel.ERROR, this, "Error painting canvas: ", e); 
     321        } 
    319322    } 
    320323 
     
    349352    } 
    350353 
    351     public void paintGeometry(Graphics2D g, FastBufferedImage imageBuffer, RenderContext lvl, BinaryInputStream is, AffineTransform defaultTransform) { 
     354    public void paintGeometry(Graphics2D g, FastBufferedImage imageBuffer, RenderContext lvl, BinaryInputStream is, AffineTransform defaultTransform) throws Exception { 
    352355        double[] v = new double[1000]; 
    353356        boolean fill = lvl.fill; 
     
    763766    } 
    764767 
    765     private void skipValues(BinaryInputStream is, int valueCount) { 
     768    private void skipValues(BinaryInputStream is, int valueCount) throws Exception { 
    766769        NumberTypeEnum t = is.readEnum(NumberTypeEnum.class); 
    767770        int bytes = numberTypeBytes[t.ordinal()]; 
     
    769772    } 
    770773 
    771     private double[] readValues(BinaryInputStream is, double[] buffer, int valueCount) { 
     774    private double[] readValues(BinaryInputStream is, double[] buffer, int valueCount) throws Exception { 
    772775        NumberTypeEnum t = is.readEnum(NumberTypeEnum.class); 
    773776        switch (t) { 
     
    837840            if (getBuffer().getByte((int)offset) == Opcode.eDEFAULT_VIEWPORT.ordinal()) { 
    838841                double[] v = new double[4]; 
    839                 BinaryInputStream stream = new BinaryInputStream(this); 
    840                 stream.skip((int)offset + 1); 
    841                 readValues(stream, v, 4); 
    842                 return new Rectangle2D.Double(v[0], v[1], v[2], v[3]); 
     842                try { 
     843                    BinaryInputStream stream = new BinaryInputStream(this); 
     844                    stream.skip((int)offset + 1); 
     845                    readValues(stream, v, 4); 
     846                    return new Rectangle2D.Double(v[0], v[1], v[2], v[3]); 
     847                } catch (Exception e) { 
     848                    Log.log(LogLevel.ERROR, this, "Error extracting bounds via viewport opcode: ", e); 
     849                } 
    843850            } 
    844851        } 
     
    906913    public void copyFrom(MemoryBuffer source) { 
    907914        super.copyFrom(source); 
    908         extractZLevels(); 
     915        try { 
     916            extractZLevels(); 
     917        } catch (Exception e) { 
     918            Log.log(LogLevel.ERROR, "Error extracting Z levels on copy: ", e); 
     919        } 
    909920    } 
    910921 
  • DistanceData.java

    r167 r171  
    3737import org.finroc.core.datatype.Unit; 
    3838import org.finroc.plugins.blackboard.BlackboardPlugin; 
    39 import org.finroc.plugins.data_types.Canvas; 
    40 import org.finroc.plugins.data_types.Dimension; 
    41 import org.finroc.plugins.data_types.Paintable; 
    42 import org.finroc.plugins.data_types.PaintablePortData; 
    43 import org.finroc.plugins.data_types.PointList; 
    44 import org.finroc.plugins.data_types.Pose3D; 
    45 import org.finroc.plugins.data_types.Time; 
    4639import org.finroc.plugins.data_types.util.BoundsExtractingGraphics2D; 
    4740import org.finroc.plugins.data_types.util.FastBufferedImage; 
     
    272265            switch (formatInfo.numberOfBytesPerValue) { 
    273266            case 1: 
    274                 return (int)(data.getBuffer().getByte(o) & 0xFF); 
     267                return data.getBuffer().getByte(o) & 0xFF; 
    275268            case 2: 
    276                 return (int)(data.getBuffer().getShort(o) & 0xFFFF); 
     269                return data.getBuffer().getShort(o) & 0xFFFF; 
    277270            case 4: 
    278271                return data.getBuffer().getFloat(o); 
     
    364357 
    365358    @Override 
    366     public void deserialize(BinaryInputStream is) { 
     359    public void deserialize(BinaryInputStream is) throws Exception { 
    367360        byte tmp = is.readByte(); 
    368361        boolean formatChanged = tmp != format; 
  • Image.java

    r156 r171  
    3636 
    3737import org.finroc.plugins.blackboard.BlackboardPlugin; 
    38 import org.finroc.plugins.data_types.Blittable; 
    39 import org.finroc.plugins.data_types.HasBlittable; 
    40 import org.finroc.plugins.data_types.PaintablePortData; 
    4138import org.finroc.plugins.data_types.util.FastBufferedImage; 
    4239import org.rrlib.logging.Log; 
     
    215212 
    216213    @Override 
    217     public void deserialize(BinaryInputStream is) { 
     214    public void deserialize(BinaryInputStream is) throws Exception { 
    218215        compressed = false; 
    219216        width = is.readInt(); 
  • Matrix.java

    r131 r171  
    6262 
    6363    @Override 
    64     public void deserialize(BinaryInputStream is) { 
     64    public void deserialize(BinaryInputStream is) throws Exception { 
    6565        for (int i = 0; i < values.length; i++) { 
    6666            values[i] = is.readDouble(); 
  • Pose2D.java

    r169 r171  
    6161 
    6262    @Override 
    63     public void deserialize(BinaryInputStream is) { 
     63    public void deserialize(BinaryInputStream is) throws Exception { 
    6464        x = is.readDouble(); 
    6565        y = is.readDouble(); 
  • Pose3D.java

    r169 r171  
    6060 
    6161    @Override 
    62     public void deserialize(BinaryInputStream is) { 
     62    public void deserialize(BinaryInputStream is) throws Exception { 
    6363        x = is.readDouble(); 
    6464        y = is.readDouble(); 
  • Time.java

    r154 r171  
    6060 
    6161    @Override 
    62     public void deserialize(BinaryInputStream is) { 
     62    public void deserialize(BinaryInputStream is) throws Exception { 
    6363        sec = (int)is.readLong(); 
    6464        usec = (int)is.readLong(); 
  • UncertainPose2D.java

    r142 r171  
    4949 
    5050    @Override 
    51     public void deserialize(BinaryInputStream is) { 
     51    public void deserialize(BinaryInputStream is) throws Exception { 
    5252        super.deserialize(is); 
    5353        matrix.deserialize(is); 
  • UncertainPose3D.java

    r133 r171  
    4949 
    5050    @Override 
    51     public void deserialize(BinaryInputStream is) { 
     51    public void deserialize(BinaryInputStream is) throws Exception { 
    5252        super.deserialize(is); 
    5353        matrix.deserialize(is); 
  • vector/Vector.java

    r168 r171  
    7676 
    7777    @Override 
    78     public void deserialize(BinaryInputStream is) { 
     78    public void deserialize(BinaryInputStream is) throws Exception { 
    7979        if (type == Type.INT) { 
    8080            for (int i = 0; i < components; i++) { 
Note: See TracChangeset for help on using the changeset viewer.