Java Code Examples for mil.nga.geopackage.extension.style.StyleRow#setColor()

The following examples show how to use mil.nga.geopackage.extension.style.StyleRow#setColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FeatureStylesUtils.java    From geopackage-android with MIT License 6 votes vote down vote up
private static StyleRow randomStyle() {
    StyleRow styleRow = new StyleRow();

    if (Math.random() < .5) {
        styleRow.setName("Style Name");
    }
    if (Math.random() < .5) {
        styleRow.setDescription("Style Description");
    }
    styleRow.setColor(randomColor());
    if (Math.random() < .5) {
        styleRow.setWidth(1.0 + (Math.random() * 3));
    }
    styleRow.setFillColor(randomColor());

    return styleRow;
}
 
Example 2
Source File: FeatureStylesUtils.java    From geopackage-java with MIT License 6 votes vote down vote up
private static StyleRow randomStyle() {
	StyleRow styleRow = new StyleRow();

	if (Math.random() < .5) {
		styleRow.setName("Style Name");
	}
	if (Math.random() < .5) {
		styleRow.setDescription("Style Description");
	}
	styleRow.setColor(randomColor());
	if (Math.random() < .5) {
		styleRow.setWidth(1.0 + (Math.random() * 3));
	}
	styleRow.setFillColor(randomColor());

	return styleRow;
}
 
Example 3
Source File: GeoPackageExample.java    From geopackage-android with MIT License 4 votes vote down vote up
private static void createFeatureStyleExtension(GeoPackage geoPackage)
        throws IOException, NameNotFoundException {

    List<StyleRow> styles = new ArrayList<>();

    StyleRow style1 = new StyleRow();
    style1.setName("Green");
    style1.setDescription("Green Style");
    style1.setColor(ColorConstants.GREEN);
    style1.setWidth(2.0);
    styles.add(style1);

    StyleRow style2 = new StyleRow();
    style2.setName("Blue with Red Fill");
    style2.setDescription("Blue with Red Fill Style");
    style2.setColor(new Color(ColorConstants.BLUE));
    style2.setFillColor(new Color(255, 0, 0, .4f));
    styles.add(style2);

    StyleRow style3 = new StyleRow();
    style3.setName("Orange");
    style3.setDescription("Orange Style");
    style3.setColor(new Color(0xFFA500));
    style3.setWidth(6.5);
    styles.add(style3);

    StyleRow style4 = new StyleRow();
    style4.setName("Violet with Yellow Fill");
    style4.setDescription("Violet with Yellow Fill Style");
    style4.setColor(new Color(138, 43, 226));
    style4.setWidth(4.1);
    style4.setFillColor(new Color(new float[]{61, .89f, .72f}, .3f));
    styles.add(style4);

    List<IconRow> icons = new ArrayList<>();

    TestUtils.copyAssetFileToInternalStorage(geoPackage.getContext(), TestUtils.getTestContext(geoPackage.getContext()), "building.png");
    IconRow icon1 = new IconRow();
    icon1.setName("Building");
    icon1.setDescription("Building Icon");
    icon1.setData(BitmapFactory.decodeFile(
            TestUtils.getAssetFileInternalStorageLocation(geoPackage.getContext(), "building.png")),
            Bitmap.CompressFormat.PNG);
    icon1.setContentType("image/png");
    icon1.setWidth(32.0);
    icon1.setAnchorU(0.5);
    icon1.setAnchorV(1.0);
    icons.add(icon1);

    TestUtils.copyAssetFileToInternalStorage(geoPackage.getContext(), TestUtils.getTestContext(geoPackage.getContext()), "college.png");
    IconRow icon2 = new IconRow();
    icon2.setName("College");
    icon2.setDescription("College Icon");
    icon2.setData(BitmapFactory.decodeFile(
            TestUtils.getAssetFileInternalStorageLocation(geoPackage.getContext(), "college.png")),
            Bitmap.CompressFormat.PNG);
    icon2.setContentType("image/png");
    icon2.setWidth(32.0);
    icon2.setHeight(44.0);
    icons.add(icon2);

    TestUtils.copyAssetFileToInternalStorage(geoPackage.getContext(), TestUtils.getTestContext(geoPackage.getContext()), "tractor.png");
    IconRow icon3 = new IconRow();
    icon3.setName("Tractor");
    icon3.setDescription("Tractor Icon");
    icon3.setData(BitmapFactory.decodeFile(
            TestUtils.getAssetFileInternalStorageLocation(geoPackage.getContext(), "tractor.png")),
            Bitmap.CompressFormat.PNG);
    icon3.setContentType("image/png");
    icon3.setAnchorV(1.0);
    icons.add(icon3);

    createFeatureStylesGeometry1(geoPackage, styles, icons);
    createFeatureStylesGeometry2(geoPackage, styles, icons);
}
 
Example 4
Source File: GeoPackageExample.java    From geopackage-java with MIT License 4 votes vote down vote up
private static void createFeatureStyleExtension(GeoPackage geoPackage)
		throws IOException {

	List<StyleRow> styles = new ArrayList<>();

	StyleRow style1 = new StyleRow();
	style1.setName("Green");
	style1.setDescription("Green Style");
	style1.setColor(ColorConstants.GREEN);
	style1.setWidth(2.0);
	styles.add(style1);

	StyleRow style2 = new StyleRow();
	style2.setName("Blue with Red Fill");
	style2.setDescription("Blue with Red Fill Style");
	style2.setColor(new Color(ColorConstants.BLUE));
	style2.setFillColor(new Color(255, 0, 0, .4f));
	styles.add(style2);

	StyleRow style3 = new StyleRow();
	style3.setName("Orange");
	style3.setDescription("Orange Style");
	style3.setColor(new Color(0xFFA500));
	style3.setWidth(6.5);
	styles.add(style3);

	StyleRow style4 = new StyleRow();
	style4.setName("Violet with Yellow Fill");
	style4.setDescription("Violet with Yellow Fill Style");
	style4.setColor(new Color(138, 43, 226));
	style4.setWidth(4.1);
	style4.setFillColor(new Color(new float[] { 61, .89f, .72f }, .3f));
	styles.add(style4);

	List<IconRow> icons = new ArrayList<>();

	IconRow icon1 = new IconRow();
	icon1.setName("Building");
	icon1.setDescription("Building Icon");
	icon1.setData(GeoPackageIOUtils
			.fileBytes(TestUtils.getTestFile("building.png")));
	icon1.setContentType("image/png");
	icon1.setWidth(32.0);
	icon1.setAnchorU(0.5);
	icon1.setAnchorV(1.0);
	icons.add(icon1);

	IconRow icon2 = new IconRow();
	icon2.setName("College");
	icon2.setDescription("College Icon");
	icon2.setData(GeoPackageIOUtils
			.fileBytes(TestUtils.getTestFile("college.png")));
	icon2.setContentType("image/png");
	icon2.setWidth(32.0);
	icon2.setHeight(44.0);
	icons.add(icon2);

	IconRow icon3 = new IconRow();
	icon3.setName("Tractor");
	icon3.setDescription("Tractor Icon");
	icon3.setData(GeoPackageIOUtils
			.fileBytes(TestUtils.getTestFile("tractor.png")));
	icon3.setContentType("image/png");
	icon3.setAnchorV(1.0);
	icons.add(icon3);

	createFeatureStylesGeometry1(geoPackage, styles, icons);
	createFeatureStylesGeometry2(geoPackage, styles, icons);

}