GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - hamzasharuf/floorplanner: A lightweight library which is used to add a polygon with 4 vetrexes over an image and allow the user to move either the whole polygon at once or the vertexes one by one.

BranchesTags
Open more actions menu

Latest commit

 

History

21 Commits
21 Commits

Folders and files

NameName
Last commit message
Last commit date
.idea
.idea
 
 
app
app
 
 
art
art
 
 
gradle/wrapper
gradle/wrapper
 
 
library
library
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
jitpack.yml
jitpack.yml
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Floor Planner

Kotlin Version API Ktlint

A lightweight library which used to add a polygon with 4 vetrexes over an image and allow the user to move either the whole polygon at once or the vertexes one by one.

Demo

Prerequisites

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
	repositories {
		...
		maven { url 'https://www.jitpack.io' }
	}
}

Dependency

Add this to your module's build.gradle file (make sure the version matches the JitPack badge above):

dependencies {
	...
	implementation 'com.github.hamzasharuf:floorplanner:1.2'
}

Usage

In your_layout.xml add the FloorPlannerView.

your_layout.xml

<com.hamzasharuf.floor_planner.FloorPlannerView
        android:id="@+id/floor_planner"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:src="@drawable/conan"
        app:boxPadding="20"
        app:fillColor="#995FAC4A"
        app:extendedTouchRadius="30"
        app:markerColor="#ff0000"
        app:polygonHeightRatio="0.75"
        app:polygonStrokeWidth="10"
        app:polygonWidthRatio="0.75"
        app:markerRadius="15"
        app:strokeColor="@color/teal_700" />

You can customize the FloorPlannerView by changing its attributes either in the xml layout or in the code.

xml properties

  • app:boxPadding="20" Add padding to the surrounding box to prevent the polygon from exceeding this padding and to have a sufficient space between the box borders and the polygon.

  • app:markerRadius="15" The radius of the marker which is used to describe a polygon vertex on the FloorPlannerView.

  • app:markerColor="#ff0000" The color of the vertexes' markers.

  • app:fillColor="#995FAC4A" The fill color of the polygon.

  • app:strokeColor="#ff018786" The stroke color of the polygon which is used to describe the sides of the polygon.

  • app:polygonStrokeWidth="10" The stroke width of the polygon which is used to describe the sides of the polygon.

  • app:polygonWidthRatio="0.75" Describes the width ratio the polygon will take out of the full FloorPlanner width once it's drawn for the first time. should be between 0.5 and 1.

  • app:polygonHeightRatio="0.75" Describes the height ratio the polygon will take out of the full FloorPlanner height once it's drawn for the first time. should be between 0.5 and 1.

  • app:extendedTouchRadius="30" Additional imaginary radius to the vertex to make the touch event on the vertex more easy for the user (To avoid forcing the user to touch the vertex itself).

Programatically

val fp = findViewById<FloorPlannerView>(R.id.floor_planner)
fp.apply {
    setExtendedTouchRadius(50)
    setBoxPadding(30f)
    setMarkerRadius(14)
    setFillColor(Color.CYAN)
    setStrokeColor(Color.GREEN)
    setMarkerColor(Color.RED)
    setPolygonHeightRatio(0.75f)
    setPolygonWidthRatio(0.75f)
    setExtendedTouchRadius(30)
}

You can extend the imaginary

You can access the Polygon or the vertexes directly

val fp = findViewById<FloorPlannerView>(R.id.floor_planner)
fp.polygon
fp.vertexes

Listeners

You can add a listener to the polygon changes and have a callback whenever the user moves the polygon or any of its vertexes.

fp.onCoordinatesUpdatedListener = object : FloorPlannerView.OnCoordinatesUpdatedListener {
    override fun onCoordinatesUpdated(polygon: Polygon) {
        Log.d(TAG, "New Vertexes Coordinates => ${polygon.vertexes}")
    }
}

Contributing

Would you like to contribute code?

  1. Fork floorplanner.
  2. Create a new branch (using GitHub) or the command git checkout -b branch-name develop).
  3. Start a pull request. Reference existing issues when possible.

License

MIT License

Copyright (c) 2021 Hamza Sharaf

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

A lightweight library which is used to add a polygon with 4 vetrexes over an image and allow the user to move either the whole polygon at once or the vertexes one by one.

Topics

androidandroid-librarycustom-viewdragkotlinpolygonvertexes

Resources

Readme
MIT license
Activity

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.