/** * Writes a list of {@code double} values as an array in X, Y, Z order. * @param output The stream to which to write the value. * @param values The values to write. */ public static void writeDoubleList(CesiumOutputStream output, Iterable<Double> values) { output.writeStartSequence(); for (final double value : values) { output.writeValue(value); } output.writeEndSequence(); }
private final void startNewValue() { if (!m_firstInContainer) { TextWriterHelper.write(m_writer, ','); } if (!m_inProperty && getPrettyFormatting() && m_nextValueOnNewLine) { TextWriterHelper.writeLine(m_writer); writeIndent(); m_nextValueOnNewLine = false; } }
/** * Writes a {@link JulianDate} as an ISO 8601 interval string. * @param output The stream to which to write the value. * @param date The date to write. */ public static void writeDate(CesiumOutputStream output, @Nonnull JulianDate date) { output.writeValue(CesiumFormattingHelper.toIso8601(date, output.getPrettyFormatting() ? Iso8601Format.EXTENDED : Iso8601Format.COMPACT)); }
output.writePropertyName(propertyName); output.writeStartSequence(); int last = startIndex + length; for (int i = startIndex; i < last; ++i) { output.writeValue(epoch.secondsDifference(dates.get(i))); Color value = values.get(i); output.writeValue(value.getRed()); output.writeValue(value.getGreen()); output.writeValue(value.getBlue()); output.writeValue(value.getAlpha()); output.writeLineBreak(); output.writeEndSequence();
/** * Writes a list of {@link TimeInterval TimeIntervals}. If the collection has a single interval, the interval is written as an ISO 8601 interval string. If it has multiple intervals, it is written as an array of ISO 8601 interval strings. * @param output The stream to which to write the value. * @param intervals The intervals to write. */ public static void writeTimeIntervalCollection(CesiumOutputStream output, List<TimeInterval> intervals) { if (intervals.size() == 1) { TimeInterval interval = intervals.get(0); writeTimeInterval(output, interval); } else { output.writeStartSequence(); for (final TimeInterval interval : intervals) { writeTimeInterval(output, interval); } output.writeEndSequence(); } }
final CesiumOutputStream tempObj$0 = new CesiumOutputStream(stringWriter); tempObj$0.setPrettyFormatting(true); cesiumlanguagewriter.CesiumOutputStream output = tempObj$0; cesiumlanguagewriter.CesiumStreamWriter writer = new CesiumStreamWriter(); output.writeStartSequence(); output.writeEndSequence(); ConsoleHelper.writeLine(stringWriter.toString()); } finally {
if (startIndex < dates.size()) { JulianDate epoch = dates.get(startIndex); output.writePropertyName("epoch"); output.writeValue(CesiumFormattingHelper.toIso8601(epoch, output.getPrettyFormatting() ? Iso8601Format.EXTENDED : Iso8601Format.COMPACT)); return epoch; } else {
@Test public void runExample() throws IOException { StringWriter stringWriter = new StringWriter(); CesiumOutputStream output = new CesiumOutputStream(stringWriter); output.setPrettyFormatting(true); CesiumStreamWriter stream = new CesiumStreamWriter(); try (PacketCesiumWriter packet = stream.openPacket(output)) { packet.writeId("Test"); try (BillboardCesiumWriter billboard = packet.openBillboardProperty()) { billboard.writeColorProperty(123, 67, 0, 255); billboard.writeImageProperty(URI.create("http://cesiumjs.org/images/CesiumHeaderLogo.png"), CesiumResourceBehavior.EMBED); } try (PositionCesiumWriter position = packet.openPositionProperty()) { position.writeCartographicDegrees(new Cartographic(-75.0, 45.0, 100.0)); } } stringWriter.close(); System.out.println(stringWriter.toString()); } }
/** * Writes the value of a property or element in a sequence. * @param value The value to write. */ public final void writeValue(@Nullable String value) { startNewValue(); m_firstInContainer = false; m_inProperty = false; if (value == null) { TextWriterHelper.write(m_writer, "null"); } else { TextWriterHelper.write(m_writer, '"'); writeEscapedString(value); TextWriterHelper.write(m_writer, '"'); } }
/** * Writes the start of a JSON sequence representing the interval list. */ @Override protected void onOpen() { getOutput().writeStartSequence(); }
/** * Writes the end of a JSON array representing the interval list. */ @Override protected void onClose() { getOutput().writeEndSequence(); }
/** * Writes the start of an object. */ public final void writeStartObject() { m_nextValueOnNewLine = true; startNewValue(); TextWriterHelper.write(m_writer, '{'); m_firstInContainer = true; m_inProperty = false; m_indent += IndentLevel; }
@Before public final void setUp() { m_stringWriter = new StringWriter(); m_outputStream = new CesiumOutputStream(m_stringWriter); }
/** * Writes the end of the JSON object representing the packet. */ @Override protected void onClose() { getOutput().writeEndObject(); }
escapedValue = c <= '\u001f' ? toCharAsUnicode(c) : null; break;
output.writePropertyName(propertyName); output.writeStartSequence(); int last = startIndex + length; for (int i = startIndex; i < last; ++i) { output.writeValue(epoch.secondsDifference(dates.get(i))); Color value = values.get(i); output.writeValue(value.getRed() / 255.0); output.writeValue(value.getGreen() / 255.0); output.writeValue(value.getBlue() / 255.0); output.writeValue(value.getAlpha() / 255.0); output.writeLineBreak(); output.writeEndSequence();
@Test public final void successiveCallsToNewPacketReturnSameInstance() { m_outputStream.writeStartSequence(); PacketCesiumWriter packet1 = m_writer.openPacket(m_outputStream); packet1.close(); PacketCesiumWriter packet2 = m_writer.openPacket(m_outputStream); packet2.close(); m_outputStream.writeEndSequence(); Assert.assertSame(packet1, packet2); }
/** * Writes the actual interval of time covered by this CZML interval. * @param interval The interval. */ public final void writeInterval(@Nonnull TimeInterval interval) { if (interval == null) { throw new ArgumentNullException("interval"); } openIntervalIfNecessary(); getOutput().writePropertyName("interval"); getOutput().writeValue(CesiumFormattingHelper.toIso8601Interval(interval.getStart(), interval.getStop(), getOutput().getPrettyFormatting() ? Iso8601Format.EXTENDED : Iso8601Format.COMPACT)); }
final CesiumOutputStream tempObj$0 = new CesiumOutputStream(stringWriter); tempObj$0.setPrettyFormatting(true); cesiumlanguagewriter.CesiumOutputStream output = tempObj$0; cesiumlanguagewriter.CesiumStreamWriter writer = new CesiumStreamWriter();