tag:blogger.com,1999:blog-11826997048639362322024-03-27T22:30:39.207-07:00Murat ÖksüzerPratik Faydalı Çözümler...Unknownnoreply@blogger.comBlogger78125tag:blogger.com,1999:blog-1182699704863936232.post-71772975351413660732024-01-09T13:31:00.000-08:002024-01-16T13:43:34.610-08:00C++ Exercises | Example Questions and Solutions [Video]<p>Here is <a href="https://www.youtube.com/playlist?list=PLzIvGBaDt2yb8-oGRfPFaNiqR6zhw8JUp" target="_blank">the Youtube Playlist</a> on my <a href="https://www.youtube.com/@muratoksuzer?sub_confirmation=1" target="_blank">channel</a> that contain C++ exercises.</p><p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://www.youtube.com/playlist?list=PLzIvGBaDt2yb8-oGRfPFaNiqR6zhw8JUp" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" data-original-height="1054" data-original-width="1880" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKifo41NeXYsr-6qrQnppjmtnpDKLH6SUUaoPQp_4HuEXx2wJ_sj2LM9QefNSlrRd9IfNVbcoeO48LfGSQPHc9nEPpDk3A-xBXODQc5MPYC5FJWmTomBwGQNGaBLV4oBkQL0DNNl9S9uTiM55BA5M4d-Ho_Dnz0nSZPnMTM1iYteSH_nluZ44ri-pb99SD/s320/blog_cpp_exercises.png" width="320" /></a></div><div style="margin-left: 40px; text-align: center;"><a href="https://www.youtube.com/playlist?list=PLzIvGBaDt2yb8-oGRfPFaNiqR6zhw8JUp" target="_blank">C++ Exercises the Youtube Playlist</a></div><p><br /></p>murathttp://www.blogger.com/profile/13233000708650902276noreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-66354088286624135292023-12-27T11:18:00.000-08:002023-12-27T11:18:06.927-08:00Unit Testing Workshop with Java | JUnit 5 Mockito JaCoCo (Video)<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://www.youtube.com/watch?v=1nyVyMahX1w" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" data-original-height="1080" data-original-width="1920" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYhx-c2nrqDPJgRZSFy6xW1-GngLzfcU_zpLptheB7vqXjuSExs2ZJRYgEzrh5b2JR4P20aWpbz4maBizf92HmfaSePOCdnIkCf02TF_GIoGJQcjRU7qFyF93RAlPn9WAqBVSVuk81ke6kWh70NC9HnFj9-7WWo8QbaZDGnl3wS5TL5VijwbF4jSGKJ11A/s320/youtube_cover.001.png" width="320" /></a></div><p></p><p><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">A comprehensive workshop about unit testing in Java using JUnit 5 (Jupiter), Mockito and JaCoCo technologies. In this tutorial, you will find lots of code examples and beneficial tips. </span></p><p><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">Outline </span></p><ul style="text-align: left;"><li><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">Importance of Unit Testing </span></li><li><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">What Is Unit Testing? </span></li><li><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">Setting Up Your Java Project JUnit Basics </span></li><li><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">Writing Your First Unit Test </span></li><li><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">Testing Exception Handling </span></li><li><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">Generating Code Coverage Report </span></li><li><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">Mocking with Mockito </span></li><li><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">Integration Testing vs Unit Testing </span></li><li><span class="yt-core-attributed-string yt-core-attributed-string--white-space-pre-wrap">Best and Worst Practices for Unit Testing</span></li></ul><p> </p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/1nyVyMahX1w" width="320" youtube-src-id="1nyVyMahX1w"></iframe></div><br /><p></p>murathttp://www.blogger.com/profile/13233000708650902276noreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-52025118686728545332023-09-13T23:10:00.004-07:002023-09-13T23:10:32.881-07:00Geospatial Workshop | Spring Boot Hibernate-Spatial PostGIS and GeoJSON Tutorial (Video)<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://youtu.be/UuNmwlHDT_E" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" data-original-height="1080" data-original-width="1920" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGSixxmsStXIZuuZp4ZccTM_OtYlVHjPg2nxVyniTwm2yoBWGnaUZOLDB7qs6ZHw5U9sQYHh93-ZYSHFsr1P5oboIY_UwZPFpsgqbvNcjTBLyl42ILufGbp4B3KgcQ9Mlp2Hf-WWdAFhe4g9Z0pyCnNSPALFp31y7VVCUFsXpdF8mvJrIWhZT23Ve9CiWc/s320/spatiallab_presentation_thumb.001.png" width="320" /></a></div><p></p><p>A sample Spring Boot application development with PostgreSql DB with
PostGIS extension, hibernate-spatial and Locationtech JTS (JTS Topology
Suite) technologies used.
This tutorial is beneficial for you to understand basic geospatial
software development. </p><p>Outline </p><ul><li>How to start geospatial Spring Boot application project </li><li>Save JTS geometry objects to PostgreSQL with PostGIS </li><li>Convert JTS geometries to GeoJSON via ultimate-geojson lib </li><li>Custom JSON serializer / deserializer for JTS Geometry to GeoJSON
conversion and vice versa. And Why do we need them? </li><li>How to perform geospatial queries (intersects & distance)</li></ul><p> </p><p></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/UuNmwlHDT_E" width="320" youtube-src-id="UuNmwlHDT_E"></iframe></div><br /> <p></p>murathttp://www.blogger.com/profile/13233000708650902276noreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-30525535242388389222023-09-06T23:00:00.015-07:002023-09-13T23:06:25.630-07:00Working With Date & Time in Spring Boot PostgreSQL Hibernate Application (Video)<p></p><div class="separator" style="clear: both; text-align: center;"></div><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://youtu.be/AMq5nCkRawc" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" data-original-height="1080" data-original-width="1920" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_gibynq1TTrLiYZTutZYlyYCwTUdcLOeaxHYiFROwYUDtTl76d_T06F8t6Ihne68deqQlPOfXfXx8cHUImUAd-XwfIvNSnGxZeBHk7LmRqRQ83gsvcoDZLwi9XUteFBnMKjK_KoAHU9rGvKqkX4VK7tX6qXD4C3-gb9XPdy0cYmZXYs36qpKMqH-09nyE/s320/date_time_thumbnail.001.png" width="320" /></a></div><p></p><p></p><p>A sample Spring Boot application with PostgreSql DB and all of possible Java date and time fields that can be mapped to SQL
timestamp
timestampz
date
time
timez columns. </p><p>Outline </p><p>Date & Time object mappings in JPA </p><p>JSON serializations of date & time fields </p><p>Search & Querying via Spring Data findBy....Between</p><p> <br /></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/AMq5nCkRawc" width="320" youtube-src-id="AMq5nCkRawc"></iframe></div><br /><p></p>murathttp://www.blogger.com/profile/13233000708650902276noreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-12979549728685235382022-12-22T13:30:00.003-08:002022-12-22T22:08:16.180-08:00How To Run GDAL from Spring Boot Application in Docker Container<p> </p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4wPaSEOBIh86aNMjCl6CsW8LkMl_pQtw6v4lAn4Q5GHy_8AN22YZ6zUxlLUUo1lLZvx2U_Bn1lFl4jUWX3VHJjIqboIDVoZAG-nM6ZSd63PxCDh6Wl6SFS8jKB9el9kWnLtzq0nVIpWRthUtuF3k9_yGGDAk1d3CMfZ_l1_dn1dfsnvcY1opcUDSaSA/s1280/kucuk-resim-docker-on-gdal.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4wPaSEOBIh86aNMjCl6CsW8LkMl_pQtw6v4lAn4Q5GHy_8AN22YZ6zUxlLUUo1lLZvx2U_Bn1lFl4jUWX3VHJjIqboIDVoZAG-nM6ZSd63PxCDh6Wl6SFS8jKB9el9kWnLtzq0nVIpWRthUtuF3k9_yGGDAk1d3CMfZ_l1_dn1dfsnvcY1opcUDSaSA/s320/kucuk-resim-docker-on-gdal.png" width="320" /></a></div> <p></p><p> Here is how I run GDAL commands from Spring Boot Java application and create a Docker image.</p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/3aa5sf2w_Wc" width="320" youtube-src-id="3aa5sf2w_Wc"></iframe></div><p><br /></p><p> To keep it simple, just create a simple spring boot application with web dependencies.</p><div style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><pre><br /><span style="color: #bbb529;">@SpringBootApplication<br /></span><span style="color: #bbb529;">@RestController<br /></span><span style="color: #cc7832;">public class </span>GDALonDockerApplication {<br /> <span style="color: #cc7832;">public final </span>Logger <span style="color: #9876aa;">LOGGER </span>= LoggerFactory.<span style="font-style: italic;">getLogger</span>(GDALonDockerApplication.<span style="color: #cc7832;">class</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;"> public static void </span><span style="color: #ffc66d;">main</span>(String[] args) {<br /> SpringApplication.<span style="font-style: italic;">run</span>(GDALonDockerApplication.<span style="color: #cc7832;">class, </span>args)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> <span style="color: #bbb529;">@RequestMapping</span>(<span style="color: #6a8759;">"/"</span>)<br /> <span style="color: #cc7832;">public </span>String <span style="color: #ffc66d;">executeGdalCommand</span>() {<br /> String[] commands = <span style="color: #6a8759;">"gdal_translate -of GTiff -co -COMPRESS=JPEG -co </span><span style="color: #cc7832;">\"</span><span style="color: #6a8759;">TILED=YES</span><span style="color: #cc7832;">\"</span><span style="color: #6a8759;"> C46104A1.TIF output.jpeg"</span>.split(<span style="color: #6a8759;">"</span><span style="background-color: #364135; color: #6a8759;"> </span><span style="color: #6a8759;">"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> try </span>{<br /><br /> Process p = Runtime.<span style="font-style: italic;">getRuntime</span>().exec(commands)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>BufferedReader input = <span style="color: #cc7832;">new </span>BufferedReader(<span style="color: #cc7832;">new </span>InputStreamReader(p.getInputStream()))<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>String line = <span style="color: #cc7832;">null;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;"> try </span>{<br /> <span style="color: #cc7832;">while </span>((line = input.readLine()) != <span style="color: #cc7832;">null</span>) {<br /> <span style="color: #9876aa;">LOGGER</span>.info(line)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /> } <span style="color: #cc7832;">catch </span>(IOException e) {<br /> e.printStackTrace()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> p.getErrorStream().close()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>p.getInputStream().close()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>p.getOutputStream().close()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>p.destroy()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>} <span style="color: #cc7832;">catch </span>(IOException e) {<br /> <span style="color: #cc7832;">throw new </span>RuntimeException(e)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /> <span style="color: #cc7832;">return </span><span style="color: #6a8759;">"GDAL command executed! Well done!"</span><span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> <span style="color: #bbb529;">@GetMapping</span>(value = <span style="color: #6a8759;">"/output"</span>)<br /> <span style="color: #cc7832;">public </span>ResponseEntity<Resource> <span style="color: #ffc66d;">getOutput</span>() {<br /> Path path = Paths.<span style="font-style: italic;">get</span>(<span style="color: #6a8759;">"./"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> try </span>{<br /> <span style="color: #cc7832;">return </span>ResponseEntity.<span style="font-style: italic;">ok</span>().header(HttpHeaders.<span style="color: #9876aa; font-style: italic;">CONTENT_DISPOSITION</span><span style="color: #cc7832;">,<br /></span><span style="color: #cc7832;"> </span><span style="color: #6a8759;">"attachment; filename=</span><span style="color: #cc7832;">\"</span><span style="color: #6a8759;">output.jpeg</span><span style="color: #cc7832;">\"</span><span style="color: #6a8759;">"</span>).body(<span style="color: #cc7832;">new </span>UrlResource(path.resolve(<span style="color: #6a8759;">"output.jpeg"</span>).toUri()))<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>} <span style="color: #cc7832;">catch </span>(MalformedURLException e) {<br /> <span style="color: #cc7832;">throw new </span>RuntimeException(e)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /> }<br />}<br /></pre></div><p> To dockerize the app, use this Dockerfile.</p><div style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><pre><span style="color: #cc7832;">FROM </span>openjdk:11-jdk-slim-buster<br /><span style="color: #cc7832;">ARG </span><span style="color: #9876aa; font-style: italic;">JAR_FILE</span>=target<span style="color: #cc7832;">/*</span>.jar<br /><span style="color: #cc7832;">COPY </span>${<span style="color: #9876aa; font-style: italic;">JAR_FILE</span>} app.jar<br /><span style="color: #cc7832;">COPY </span>C46104A1.TIF C46104A1.TIF<br /><span style="color: #cc7832;">RUN </span><span style="color: #c57633;">apt-get </span>update<br /><span style="color: #cc7832;">RUN </span><span style="color: #c57633;">apt-get </span><span style="color: #cc7832;">-</span>y install libgdal-dev<br /><span style="color: #cc7832;">RUN </span><span style="color: #c57633;">apt-get </span><span style="color: #cc7832;">-</span>y install gdal-data<br /><span style="color: #cc7832;">RUN </span><span style="color: #c57633;">apt-get </span><span style="color: #cc7832;">-</span>y install gdal-bin<br /><span style="color: #cc7832;">RUN </span><span style="color: #c57633;">gdalinfo </span><span style="color: #cc7832;">--</span>version<br /><span style="color: #cc7832;">ENTRYPOINT </span>[<span style="color: #6a8759;">"java"</span><span style="color: #cc7832;">,</span><span style="color: #6a8759;">"-jar"</span><span style="color: #cc7832;">,</span><span style="color: #6a8759;">"/app.jar"</span>]</pre></div><p></p><p><br /><br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-18826562103796932132022-01-08T22:56:00.002-08:002022-01-09T03:22:37.457-08:00MaFiA: Manipulate Files Asynchronously - Asynchronous File Manipulation Service Spring Boot Application<p>Manipulate Files Asynchronously (MaFiA): Asynchronous file manipulation service, designed for microservice architectured projects, is now avaliable <a href="https://github.com/mokszr/mafia" target="_blank">on GitHub here!</a></p><p>Most of the big web peojects requires file manipulation. Some images needed to be scaled, some documents needed to be converted from docx to pdf, pdf to image, excel (xlsx) to pdf reports, or between any format. Some part of a file needed to be extracted somewhere else, etc... While implementing these tasks, you, developers, need to implement some kind of management codes too. You need to keep track of which files are processed, which ones are waiting. You need to be sure that all files are processed. You need asynchronous processing in order to gain time and non-blocking computing.<br /></p><p>At this point, MaFiA is here to execute! <span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Developers will only develop manipulation logic they need and apart from that, every management requirement will be ready on this tiny microservice: MaFiA.</span></p><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"> </span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgT1i8H7BSAx9ryz0lbPHePjoScIDIT365i4do7iNNbOa7si4XnqWQS_SL4sZygtaHX8RQOz6VRPRJY6OH7W_4yQPcTCntaKj2aUSqsyWQHZxxgEMcHHw_T8coOCs96G1YlEWKD_GK6ADdDv0KJPwiXutFgbuklcHa0S0n8RSP704t5YJM7LYWpL_M=s551" style="margin-left: 1em; margin-right: 1em;"><img alt="Mafia: Asynchronous File Manipulation" border="0" data-original-height="400" data-original-width="551" height="290" src="https://blogger.googleusercontent.com/img/a/AVvXsEgT1i8H7BSAx9ryz0lbPHePjoScIDIT365i4do7iNNbOa7si4XnqWQS_SL4sZygtaHX8RQOz6VRPRJY6OH7W_4yQPcTCntaKj2aUSqsyWQHZxxgEMcHHw_T8coOCs96G1YlEWKD_GK6ADdDv0KJPwiXutFgbuklcHa0S0n8RSP704t5YJM7LYWpL_M=w400-h290" title="Mafia: Asynchronous File Manipulation" width="400" /></a></div>Here is the ready features in this Spring Boot application code base:<p></p><ul style="text-align: left;"><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Provide simple RESTFul API. <br /></span></li><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Create file manipulation job by uploading a file with manipulation parameters and get a UUID for the process. For example, upload a big resolution image.<br /></span></li><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Determine which manipulation is needed to apply to the uploaded file in parameters. i.e. say "scale_image".<br /></span></li><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Give job specific parameters. i.e. give scale factor as 0.3.</span></li><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Query the job status using generated UUID.</span></li><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Download output file using generated UUID.</span></li><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">At configuration file (application.properties) define whatever executor pool size you want. You can increase the executor thread pool size in order to increase number of files to manipulate simultaneously.</span></li><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Define your own manipulation logic and integrate easily into application. <br /></span></li></ul><p style="text-align: left;"><b><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Test Demos on <a href="https://www.youtube.com/watch?v=gJm9go2V8tc" target="_blank">Youtube here:</a> </span></b></p><p style="text-align: left;"></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="313" src="https://www.youtube.com/embed/gJm9go2V8tc" width="377" youtube-src-id="gJm9go2V8tc"></iframe></div><br /><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"><br /></span><p></p><h2 style="text-align: left;"><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">How Can I Define and Integrate My Own File Manipulation Logic?</span></h2><p style="text-align: left;"><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">You only need to</span></p><ul style="text-align: left;"><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Create a manipulation class that extends <b>AbstractManipulation</b></span></li><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Implement the <b>applyManipulation()</b> method</span></li><li><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Register this new class to <b>ManipulationStoreService </b>in the <b>InitManipulationStoreService </b>class <br /></span></li></ul><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;"></span><span style="color: #333333;"></span></pre><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"></span></p><div align="left" dir="ltr" id="docs-internal-guid-ff533dc0-7fff-b215-52f2-337d87f50db7" style="margin-left: 0pt;"><table style="border-collapse: collapse; border: medium none; table-layout: fixed; width: 451.276pt;"><colgroup><col></col></colgroup><tbody><tr style="height: 0pt;"><td style="border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;"><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">package</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> com</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">smartycoder</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">mafia</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">store</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">java.nio.file.Path</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">java.util.Map</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.commons.io.FileUtils</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">com.smartycoder.mafia.manipulation.AbstractManipulation</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">public</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">class</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #bb0066; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">JustCopyManipulation</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">extends</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> AbstractManipulation </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">{</span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #555555; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">@Override</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">public</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333399; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">void</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #0066bb; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">applyManipulation</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Path uploadedFilePath</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> Path outputFilePath</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Map</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">String</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> String</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> manipulationParameters</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">)</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">throws</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> Throwable </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">{</span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> FileUtils</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">copyFile</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">uploadedFilePath</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">toFile</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">(),</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> outputFilePath</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">toFile</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">());</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">}</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">}</span></p><br /></td></tr></tbody></table></div><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"></span></p><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Here is the <b>InitManipulationStoreService</b></span></p><div align="left" dir="ltr" id="docs-internal-guid-bc22f717-7fff-a572-639c-e5a5b1af9eb0" style="margin-left: 0pt;"><table style="border-collapse: collapse; border: medium none; table-layout: fixed; width: 451.276pt;"><colgroup><col></col></colgroup><tbody><tr style="height: 0pt;"><td style="border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;"><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #555555; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">@Component</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #555555; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">@Order</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #0000dd; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">1</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">)</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">public</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">class</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #bb0066; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">InitManipulationStoreService</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">implements</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> ApplicationListener<ApplicationReadyEvent>{</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #555555; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">@Autowired</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">private</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> ManipulationStoreService manipulationStoreService;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #555555; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">@Override</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">public</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333399; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">void</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #0066bb; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">onApplicationEvent</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">(ApplicationReadyEvent event) {</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">manipulationStoreService.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">registerManipulation</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">"justcopy"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">, JustCopyManipulation.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">class</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">manipulationStoreService.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">registerManipulation</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">"scale_image"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">, ScaleImageManipulation.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">class</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">}</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">}</span></p><br /></td></tr></tbody></table></div><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"></span></p><h2 style="text-align: left;"><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">How Can I Test It?</span></h2><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Here is an example MaFiA usage for a single image file. In this example, we use <b>Apache HttpClient</b> to consume MaFiA REST API, send HTTP requests and receive responses.</span></p><div align="left" dir="ltr" id="docs-internal-guid-cd5c1ee1-7fff-0ea5-ec52-0c8de1a1573d" style="margin-left: 0pt;"><table style="border-collapse: collapse; border: medium none; table-layout: fixed; width: 451.276pt;"><colgroup><col></col></colgroup><tbody><tr style="height: 0pt;"><td style="border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;"><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">java.io.BufferedInputStream</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">java.io.BufferedOutputStream</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">java.io.File</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">java.io.FileOutputStream</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">java.io.IOException</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.commons.io.IOUtils</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.HttpEntity</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.HttpResponse</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.client.ClientProtocolException</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.client.HttpClient</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.client.methods.HttpGet</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.client.methods.HttpPost</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.entity.ContentType</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.entity.mime.MultipartEntityBuilder</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.entity.mime.content.FileBody</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.entity.mime.content.StringBody</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.apache.http.impl.client.HttpClientBuilder</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">import </span><span style="background-color: transparent; color: #0e84b5; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">org.json.JSONObject</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">public class </span><span style="background-color: transparent; color: #bb0066; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">MAFIAClient</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">{</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">public static </span><span style="background-color: transparent; color: #333399; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">void</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #0066bb; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">main</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">String</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">[]</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> args</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">)</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> throws ClientProtocolException</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> IOException</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> InterruptedException </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">{</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">File file </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new File</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"image1.jpg"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">HttpPost httpPost </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new HttpPost</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"http://localhost:8080/job-management/mafia-jobs"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">JSONObject manParms </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new JSONObject</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">();</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">manParms</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">put</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"scale"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"0.3"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">JSONObject jsonObject </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new JSONObject</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">();</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">jsonObject</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">put</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"fileType"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"JPEG"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">jsonObject</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">put</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"manipulationName"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"scale_image"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">jsonObject</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">put</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"manipulationParameters"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> manParms</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">StringBody userBody </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new StringBody</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">jsonObject</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">toString</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(),</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> ContentType</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">APPLICATION_JSON</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">FileBody fileBody </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new FileBody</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">file</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> ContentType</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">DEFAULT_BINARY</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">MultipartEntityBuilder entityBuilder </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> MultipartEntityBuilder</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">create</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">();</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">entityBuilder</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">addPart</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"mafiaJob"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> userBody</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">entityBuilder</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">addPart</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"file"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">,</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> fileBody</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">HttpEntity entity </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> entityBuilder</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">build</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">();</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">httpPost</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">setEntity</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">entity</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">HttpClient client </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> HttpClientBuilder</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">create</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">().</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">build</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">();</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">HttpResponse response </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> client</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">execute</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">httpPost</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">HttpEntity responseEntity </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> response</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">getEntity</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">();</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #888888; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">// print response</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">String responseString </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> IOUtils</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">toString</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">responseEntity</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">getContent</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(),</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"utf8"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">System</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">out</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">println</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">responseString</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">JSONObject responseJson </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new JSONObject</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">responseString</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">String responseUuid </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">String</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">)</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> responseJson</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">get</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"uuid"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">while </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">true</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">)</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">{</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">HttpGet httpGet </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new HttpGet</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"http://localhost:8080/job-management/mafia-jobs/status/"</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">+</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> responseUuid</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">HttpEntity statusResponse </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> client</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">execute</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">httpGet</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">).</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">getEntity</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">();</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">String statusResponseString </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> IOUtils</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">toString</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">statusResponse</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">getContent</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(),</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"utf8"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">System</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">out</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">println</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">statusResponseString</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">JSONObject statusResponseJson </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new JSONObject</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">statusResponseString</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">if </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"FINISHED"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">equals</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">statusResponseJson</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">get</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"status"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">)))</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">{</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">break</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">}</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">Thread</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">sleep</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #0000dd; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">500</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">}</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">HttpGet httpGet </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new HttpGet</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"http://localhost:8080/job-management/mafia-jobs/output/"</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">+</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> responseUuid</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">HttpEntity outputResponse </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> client</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">execute</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">httpGet</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">).</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">getEntity</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">();</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">BufferedInputStream bis </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new BufferedInputStream</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">outputResponse</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">getContent</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">());</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">String filePath </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"scaledImae.png"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">BufferedOutputStream bos </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> new BufferedOutputStream</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">new FileOutputStream</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">new File</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">filePath</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">)));</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333399; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">int</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> inByte</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">;</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">while </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">((</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">inByte </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> bis</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">read</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">())</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">!=</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">-</span><span style="background-color: transparent; color: #0000dd; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">1</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">)</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">bos</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">write</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">inByte</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">bis</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">close</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">();</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">bos</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">close</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">();</span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span></p><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">System</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">out</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">.</span><span style="background-color: transparent; color: #0000cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">println</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">(</span><span style="background-color: #fff0f0; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">"Download finished"</span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">);</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #008800; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">}</span></p><br /><p dir="ltr" style="line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: #333333; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">}</span></p><br /><br /></td></tr></tbody></table></div><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"></span></p><h2 style="text-align: left;"><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Which Technologies Are Used in MaFiA?</span></h2><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">MaFiA is a Spring Boot application. For database, it uses PostgreSql. There is no security implementation here because every project has its own different security approach. One developer can easily integrate security logic into MaFiA. It is open source and <a href="https://github.com/mokszr/mafia" target="_blank">freely available on GitHub here.</a></span></p><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Similarly if you want, database technology or file storage method can be cutomized easily for your own project technology stack.</span></p><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">For 100 files manipulation and 1000 files multi threaded file manipulation client examples <a href="https://www.youtube.com/watch?v=gJm9go2V8tc" target="_blank">watch this demo on Youtube:</a><br /></span></p><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"><br /></span></p><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"><br /></span></p><p><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"><br /></span></p>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-1182699704863936232.post-28642675801618061152021-07-04T05:54:00.003-07:002021-07-04T05:57:31.750-07:00Android SQLite Kullanımı Örneği<p>Android uygulamalarımızda kalıcı veri saklamak istediğimizde kullandığımız yöntemlerden biri de SQLite veritabanı kullanmaktır. Bu yazımda SQLite kullanarak örnek bir Customer tablosu oluşturmayı ve imajdan tarihe, string'den para verisine kadar çok çeşitli veri tiplerinde nasıl veri kaydedeceğimizi ve okuyacağımızı göreceğiz.</p><p> <table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHYg3YP1tV_gKHWC4snJXr6AUqKl359tDbUjt1YucgzzlcXor5SwAH53VfH1rH-NOliz7t5MOCyoTvLaUEh_gERvQkou30aB0oJX5g30egr_eyzR6DUinRaLwyxtAw4VBs8WaJ2UPyTUM/s600/android_sqlite_ornek_kullanimi.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Android SQLite Kullanımı Örneği" border="0" data-original-height="550" data-original-width="600" height="366" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHYg3YP1tV_gKHWC4snJXr6AUqKl359tDbUjt1YucgzzlcXor5SwAH53VfH1rH-NOliz7t5MOCyoTvLaUEh_gERvQkou30aB0oJX5g30egr_eyzR6DUinRaLwyxtAw4VBs8WaJ2UPyTUM/w400-h366/android_sqlite_ornek_kullanimi.png" title="Android SQLite Kullanımı Örneği" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Android SQLite Kullanımı Örneği</td></tr></tbody></table><br /><p> </p><p>Öncelikle <b>Customer.java </b>veri sınıfımızı inceleyelim:</p><div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.graphics.Bitmap</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.math.BigDecimal</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Date</span><span style="color: #333333;">;</span>
// see muratoksuzer.com
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Customer</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> Long id<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String code<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String name<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String surname<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Integer price <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Bitmap image<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String phone<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String address<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String notes<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Date date<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> Long <span style="color: #0066bb; font-weight: bold;">getId</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> id<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setId</span><span style="color: #333333;">(</span>Long id<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">id</span> <span style="color: #333333;">=</span> id<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getCode</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> code<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setCode</span><span style="color: #333333;">(</span>String code<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">code</span> <span style="color: #333333;">=</span> code<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getName</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> name<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setName</span><span style="color: #333333;">(</span>String name<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">name</span> <span style="color: #333333;">=</span> name<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getSurname</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> surname<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setSurname</span><span style="color: #333333;">(</span>String surname<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">surname</span> <span style="color: #333333;">=</span> surname<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> Integer <span style="color: #0066bb; font-weight: bold;">getPrice</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> price<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setPrice</span><span style="color: #333333;">(</span>Integer price<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">price</span> <span style="color: #333333;">=</span> price<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getPriceText</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
BigDecimal decimal <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> BigDecimal<span style="color: #333333;">(</span>price<span style="color: #333333;">);</span>
BigDecimal divided <span style="color: #333333;">=</span> decimal<span style="color: #333333;">.</span><span style="color: #0000cc;">divide</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> BigDecimal<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">));</span>
<span style="color: #008800; font-weight: bold;">return</span> divided<span style="color: #333333;">.</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> Bitmap <span style="color: #0066bb; font-weight: bold;">getImage</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> image<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setImage</span><span style="color: #333333;">(</span>Bitmap image<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">image</span> <span style="color: #333333;">=</span> image<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getPhone</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> phone<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setPhone</span><span style="color: #333333;">(</span>String phone<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">phone</span> <span style="color: #333333;">=</span> phone<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getAddress</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> address<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setAddress</span><span style="color: #333333;">(</span>String address<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">address</span> <span style="color: #333333;">=</span> address<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getNotes</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> notes<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setNotes</span><span style="color: #333333;">(</span>String notes<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">notes</span> <span style="color: #333333;">=</span> notes<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> Date <span style="color: #0066bb; font-weight: bold;">getDate</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> date<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setDate</span><span style="color: #333333;">(</span>Date date<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">date</span> <span style="color: #333333;">=</span> date<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><p>Para verisi hassas veri olduğundan küsüratlardaki hatayı kaldıramaz. Bu nedenle veriyi saklarken 100 ile çarpıp noktalı sayılardan kurtararak Integer tipinde saklıyoruz. Okurken de 100 ile bölerek okuyoruz. Resim foto verisi için <b>android.graphics.Bitmap </b>sınıfını kullanıyoruz.<b> </b>SQLite veritabanına kaydederken bu nesneyi byte array'ine (byte[]) çevirip kaydedeceğiz. </p><p>Şimdi de Android'de SQLite kullanımında veritabanını oluşturmaktan, gerekirse tabloları güncellemekten sorumlu olan <b>android.database.sqlite.SQLiteOpenHelper</b> sınıfından türettiğimiz <b>CustomerSQLiteHelper</b><b>.java</b> yardımcı sınıfımızı inceleyelim.</p><div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.content.Context</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.database.sqlite.SQLiteDatabase</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.database.sqlite.SQLiteOpenHelper</span><span style="color: #333333;">;</span>
<span style="color: #888888;">/**</span>
<span style="color: #888888;"> * @author moksuzer</span>
<span style="color: #888888;"> * @see muratoksuzer.com</span>
<span style="color: #888888;"> */</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">CustomerSQLiteHelper</span> <span style="color: #008800; font-weight: bold;">extends</span> SQLiteOpenHelper <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String TABLE_CUSTOMERS <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"customers"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String COLUMN_ID <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"_id"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String COLUMN_CODE <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"code"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String COLUMN_NAME <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"name"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String COLUMN_SURNAME <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"surname"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String COLUMN_PHONE <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"phone"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String COLUMN_ADDRESS <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"address"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String COLUMN_DATE <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"zaman"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String COLUMN_IMAGE <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"image"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String COLUMN_NOTES <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"notes"</span><span style="color: #333333;">;</span>
<span style="color: #888888;">// price column gercek fiyatin 100 katini tutuyor. noktali sayilarla ugrasmamak icin</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String COLUMN_FEE <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"fee"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String DATABASE_NAME <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"customers.db"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> <span style="color: #333399; font-weight: bold;">int</span> DATABASE_VERSION <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span>
<span style="color: #888888;">// Database creation sql statement</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String DATABASE_CREATE <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"create table "</span>
<span style="color: #333333;">+</span> TABLE_CUSTOMERS <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> COLUMN_ID
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" integer primary key autoincrement, "</span>
<span style="color: #333333;">+</span> COLUMN_CODE <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" text not null, "</span>
<span style="color: #333333;">+</span> COLUMN_NAME <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" text, "</span>
<span style="color: #333333;">+</span> COLUMN_SURNAME <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" text, "</span>
<span style="color: #333333;">+</span> COLUMN_FEE <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" INTEGER ,"</span>
<span style="color: #333333;">+</span> COLUMN_IMAGE <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" blob, "</span>
<span style="color: #333333;">+</span> COLUMN_PHONE <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" text ,"</span>
<span style="color: #333333;">+</span> COLUMN_ADDRESS <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" text ,"</span>
<span style="color: #333333;">+</span> COLUMN_DATE <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" real ,"</span>
<span style="color: #333333;">+</span> COLUMN_NOTES <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" text "</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">");"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">CustomerSQLiteHelper</span><span style="color: #333333;">(</span>Context context<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">super</span><span style="color: #333333;">(</span>context<span style="color: #333333;">,</span> DATABASE_NAME<span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> DATABASE_VERSION<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onCreate</span><span style="color: #333333;">(</span>SQLiteDatabase database<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
database<span style="color: #333333;">.</span><span style="color: #0000cc;">execSQL</span><span style="color: #333333;">(</span>DATABASE_CREATE<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onUpgrade</span><span style="color: #333333;">(</span>SQLiteDatabase db<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> oldVersion<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> newVersion<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><p>Para verisini kaydedeceğimiz kolonun INTEGER, resim kaydedeceğimiz kolonun BLOB, tarih kaydedeceğimiz kolonun REAL veri tipinde olduğunu görüyoruz. Normal metin kaydedeceğimiz kolonların ise TEXT olarak belirlendiğini görüyoruz.</p><p>onCreate() metodunda eğer ilk defa çalıştırılıyorsa tabloyu oluşturmak için DATABASE_CREATE sql kodu çalıştırılıyor. Eğer tabloyu sonraki sürümlerde değiştirmek istiyorsak mevcut verileri kaybetmemek için DATABASE_VERSION değerini bir arttırmamız ve onUpgrade() metodunda tabloyu güncelleyecek sql kodunu çalıştırmamız gerekir.<br /></p><p>Şimdi de veri tabanı işlemlerini uygulama mantığı işlerinden soyutlamak için kullanacağımız, sadece veri tabanı işlemlerinden sorumlu olan (bakınız Single Responsibility Principle) DAO (data access object) sınıfımız olan <b>CustomerDAO</b><b><b>.java</b> </b>sınıfını inceleyelim.</p><div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.content.ContentValues</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.content.Context</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.database.Cursor</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.database.SQLException</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.database.sqlite.SQLiteDatabase</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.graphics.Bitmap</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.graphics.BitmapFactory</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.io.ByteArrayOutputStream</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.ArrayList</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Date</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.List</span><span style="color: #333333;">;</span>
<span style="color: #888888;">/**</span>
<span style="color: #888888;"> * @author moksuzer</span>
<span style="color: #888888;"> * @see muratoksuzer.com</span>
<span style="color: #888888;"> */</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">CustomerDAO</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> SQLiteDatabase database<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> CustomerSQLiteHelper dbHelper<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Context context<span style="color: #333333;">;</span>
<span style="color: #888888;">//imaj gerekmeyen sorgularda bunu kullanacagiz</span>
<span style="color: #008800; font-weight: bold;">private</span> String<span style="color: #333333;">[]</span> allSimpleColumns <span style="color: #333333;">=</span> <span style="color: #333333;">{</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ID</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_CODE</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_NAME</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_SURNAME</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_FEE</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_PHONE</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ADDRESS</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_DATE</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_NOTES</span><span style="color: #333333;">};</span>
<span style="color: #888888;">//imaji da okumak istedigimizde bunu kullanacagiz</span>
<span style="color: #008800; font-weight: bold;">private</span> String<span style="color: #333333;">[]</span> allColumns <span style="color: #333333;">=</span> <span style="color: #333333;">{</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ID</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_CODE</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_NAME</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_SURNAME</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_FEE</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_IMAGE</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_PHONE</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ADDRESS</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_DATE</span><span style="color: #333333;">,</span>
CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_NOTES</span><span style="color: #333333;">};</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">CustomerDAO</span><span style="color: #333333;">(</span>Context context<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
dbHelper <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> CustomerSQLiteHelper<span style="color: #333333;">(</span>context<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">context</span> <span style="color: #333333;">=</span> context<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">open</span><span style="color: #333333;">()</span> <span style="color: #008800; font-weight: bold;">throws</span> SQLException <span style="color: #333333;">{</span>
database <span style="color: #333333;">=</span> dbHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">getWritableDatabase</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">close</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
dbHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> Customer <span style="color: #0066bb; font-weight: bold;">create</span><span style="color: #333333;">(</span>Customer customer<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
ContentValues values <span style="color: #333333;">=</span> buildContentValuesImageAdded<span style="color: #333333;">(</span>customer<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">long</span> insertId <span style="color: #333333;">=</span> database<span style="color: #333333;">.</span><span style="color: #0000cc;">insert</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">TABLE_CUSTOMERS</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span>
values<span style="color: #333333;">);</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setId</span><span style="color: #333333;">(</span>insertId<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">return</span> customer<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">delete</span><span style="color: #333333;">(</span>Customer customer<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
database<span style="color: #333333;">.</span><span style="color: #0000cc;">delete</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">TABLE_CUSTOMERS</span><span style="color: #333333;">,</span> CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ID</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" = ?"</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span>Long<span style="color: #333333;">.</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">(</span>customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getId</span><span style="color: #333333;">())});</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">update</span><span style="color: #333333;">(</span>Customer customer<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>customer <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span> <span style="color: #333333;">||</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getId</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
ContentValues values <span style="color: #333333;">=</span> buildContentValuesImageAdded<span style="color: #333333;">(</span>customer<span style="color: #333333;">);</span>
database<span style="color: #333333;">.</span><span style="color: #0000cc;">update</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">TABLE_CUSTOMERS</span><span style="color: #333333;">,</span> values<span style="color: #333333;">,</span> CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ID</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" = ?"</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span>customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getId</span><span style="color: #333333;">().</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">()});</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">updateExcepImage</span><span style="color: #333333;">(</span>Customer customer<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>customer <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span> <span style="color: #333333;">||</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getId</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
ContentValues values <span style="color: #333333;">=</span> buildContentValues<span style="color: #333333;">(</span>customer<span style="color: #333333;">);</span>
database<span style="color: #333333;">.</span><span style="color: #0000cc;">update</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">TABLE_CUSTOMERS</span><span style="color: #333333;">,</span> values<span style="color: #333333;">,</span> CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ID</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" = ?"</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span>customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getId</span><span style="color: #333333;">().</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">()});</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> List<span style="color: #333333;"><</span>Customer<span style="color: #333333;">></span> <span style="color: #0066bb; font-weight: bold;">getAllCustomers</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
List<span style="color: #333333;"><</span>Customer<span style="color: #333333;">></span> customers <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><</span>Customer<span style="color: #333333;">>();</span>
Cursor cursor <span style="color: #333333;">=</span> database<span style="color: #333333;">.</span><span style="color: #0000cc;">query</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">TABLE_CUSTOMERS</span><span style="color: #333333;">,</span>
allSimpleColumns<span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">moveToFirst</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(!</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">isAfterLast</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
Customer customer <span style="color: #333333;">=</span> cursorToCustomer<span style="color: #333333;">(</span>cursor<span style="color: #333333;">);</span>
customers<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>customer<span style="color: #333333;">);</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">moveToNext</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// make sure to close the cursor</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">return</span> customers<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> Bitmap <span style="color: #0066bb; font-weight: bold;">getImage</span><span style="color: #333333;">(</span>Long id<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>id <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
Cursor cursor <span style="color: #333333;">=</span> database<span style="color: #333333;">.</span><span style="color: #0000cc;">query</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">TABLE_CUSTOMERS</span><span style="color: #333333;">,</span>
allColumns<span style="color: #333333;">,</span> CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ID</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" = ?"</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span>id<span style="color: #333333;">.</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">()},</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>cursor <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
Customer customer <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">moveToFirst</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(!</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">isAfterLast</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
customer <span style="color: #333333;">=</span> cursorToCustomerImageRead<span style="color: #333333;">(</span>cursor<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">return</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getImage</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> Customer <span style="color: #0066bb; font-weight: bold;">findcustomer</span><span style="color: #333333;">(</span>Long id<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>id <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
Cursor cursor <span style="color: #333333;">=</span> database<span style="color: #333333;">.</span><span style="color: #0000cc;">query</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">TABLE_CUSTOMERS</span><span style="color: #333333;">,</span>
allColumns<span style="color: #333333;">,</span> CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ID</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" = ?"</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span>id<span style="color: #333333;">.</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">()},</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>cursor <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
Customer customer <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">moveToFirst</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(!</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">isAfterLast</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
customer <span style="color: #333333;">=</span> cursorToCustomerImageRead<span style="color: #333333;">(</span>cursor<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">return</span> customer<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> Customer <span style="color: #0066bb; font-weight: bold;">findCustomerByCode</span><span style="color: #333333;">(</span>String code<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
Cursor cursor <span style="color: #333333;">=</span> database<span style="color: #333333;">.</span><span style="color: #0000cc;">query</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">TABLE_CUSTOMERS</span><span style="color: #333333;">,</span>
allSimpleColumns<span style="color: #333333;">,</span> CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_CODE</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" = ?"</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span>code<span style="color: #333333;">},</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>cursor <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
Customer customer <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">moveToFirst</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(!</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">isAfterLast</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
customer <span style="color: #333333;">=</span> cursorToCustomer<span style="color: #333333;">(</span>cursor<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">return</span> customer<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> Customer <span style="color: #0066bb; font-weight: bold;">findCustomerByCodeAddImage</span><span style="color: #333333;">(</span>String code<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
Cursor cursor <span style="color: #333333;">=</span> database<span style="color: #333333;">.</span><span style="color: #0000cc;">query</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">TABLE_CUSTOMERS</span><span style="color: #333333;">,</span>
allColumns<span style="color: #333333;">,</span> CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_CODE</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" = ?"</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span>code<span style="color: #333333;">},</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>cursor <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
Customer customer <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">moveToFirst</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(!</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">isAfterLast</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
customer <span style="color: #333333;">=</span> cursorToCustomerImageRead<span style="color: #333333;">(</span>cursor<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">return</span> customer<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> ContentValues <span style="color: #0066bb; font-weight: bold;">buildContentValues</span><span style="color: #333333;">(</span>Customer customer<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
ContentValues values <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ContentValues<span style="color: #333333;">();</span>
values<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_CODE</span><span style="color: #333333;">,</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getCode</span><span style="color: #333333;">());</span>
values<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_NAME</span><span style="color: #333333;">,</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getName</span><span style="color: #333333;">());</span>
values<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_SURNAME</span><span style="color: #333333;">,</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getSurname</span><span style="color: #333333;">());</span>
values<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_FEE</span><span style="color: #333333;">,</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getPrice</span><span style="color: #333333;">());</span>
values<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_PHONE</span><span style="color: #333333;">,</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getPhone</span><span style="color: #333333;">());</span>
values<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ADDRESS</span><span style="color: #333333;">,</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getAddress</span><span style="color: #333333;">());</span>
values<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_NOTES</span><span style="color: #333333;">,</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getNotes</span><span style="color: #333333;">());</span>
values<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_DATE</span><span style="color: #333333;">,</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getDate</span><span style="color: #333333;">()</span> <span style="color: #333333;">!=</span> <span style="color: #008800; font-weight: bold;">null</span> <span style="color: #333333;">?</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getDate</span><span style="color: #333333;">().</span><span style="color: #0000cc;">getTime</span><span style="color: #333333;">():</span><span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">return</span> values<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> ContentValues <span style="color: #0066bb; font-weight: bold;">buildContentValuesImageAdded</span><span style="color: #333333;">(</span>Customer customer<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
ContentValues values <span style="color: #333333;">=</span> buildContentValues<span style="color: #333333;">(</span>customer<span style="color: #333333;">);</span>
Bitmap image <span style="color: #333333;">=</span> customer<span style="color: #333333;">.</span><span style="color: #0000cc;">getImage</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>image <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
values<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_IMAGE</span><span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">new</span> <span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">]);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
values<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_IMAGE</span><span style="color: #333333;">,</span> getBytes<span style="color: #333333;">(</span>image<span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> values<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> Customer <span style="color: #0066bb; font-weight: bold;">cursorToCustomer</span><span style="color: #333333;">(</span>Cursor cursor<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
Customer customer <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Customer<span style="color: #333333;">();</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setId</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getLong</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">));</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setCode</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getColumnIndex</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_CODE</span><span style="color: #333333;">)));</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setName</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getColumnIndex</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_NAME</span><span style="color: #333333;">)));</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setSurname</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getColumnIndex</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_SURNAME</span><span style="color: #333333;">)));</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setPrice</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getInt</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getColumnIndex</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_FEE</span><span style="color: #333333;">)));</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setPhone</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getColumnIndex</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_PHONE</span><span style="color: #333333;">)));</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setAddress</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getColumnIndex</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_ADDRESS</span><span style="color: #333333;">)));</span>
<span style="color: #333399; font-weight: bold;">long</span> time <span style="color: #333333;">=</span> cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getLong</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getColumnIndex</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_DATE</span><span style="color: #333333;">));</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setDate</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Date<span style="color: #333333;">(</span>time<span style="color: #333333;">));</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setNotes</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getColumnIndex</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_NOTES</span><span style="color: #333333;">)));</span>
<span style="color: #008800; font-weight: bold;">return</span> customer<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> Customer <span style="color: #0066bb; font-weight: bold;">cursorToCustomerImageRead</span><span style="color: #333333;">(</span>Cursor cursor<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
Customer customer <span style="color: #333333;">=</span> cursorToCustomer<span style="color: #333333;">(</span>cursor<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[]</span> blob <span style="color: #333333;">=</span> cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getBlob</span><span style="color: #333333;">(</span>cursor<span style="color: #333333;">.</span><span style="color: #0000cc;">getColumnIndex</span><span style="color: #333333;">(</span>CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">COLUMN_IMAGE</span><span style="color: #333333;">));</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>blob <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span> <span style="color: #333333;">||</span> blob<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span> <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setImage</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
customer<span style="color: #333333;">.</span><span style="color: #0000cc;">setImage</span><span style="color: #333333;">(</span>getImage<span style="color: #333333;">(</span>blob<span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> customer<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getCount</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
String query <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" SELECT count(*) from "</span> <span style="color: #333333;">+</span> CustomerSQLiteHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">TABLE_CUSTOMERS</span><span style="color: #333333;">;</span>
Cursor mCount <span style="color: #333333;">=</span> database<span style="color: #333333;">.</span><span style="color: #0000cc;">rawQuery</span><span style="color: #333333;">(</span>query<span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
mCount<span style="color: #333333;">.</span><span style="color: #0000cc;">moveToFirst</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">int</span> count <span style="color: #333333;">=</span> mCount<span style="color: #333333;">.</span><span style="color: #0000cc;">getInt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">);</span>
mCount<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">return</span> count<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[]</span> <span style="color: #0066bb; font-weight: bold;">getBytes</span><span style="color: #333333;">(</span>Bitmap bitmap<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
ByteArrayOutputStream stream <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ByteArrayOutputStream<span style="color: #333333;">();</span>
bitmap<span style="color: #333333;">.</span><span style="color: #0000cc;">compress</span><span style="color: #333333;">(</span>Bitmap<span style="color: #333333;">.</span><span style="color: #0000cc;">CompressFormat</span><span style="color: #333333;">.</span><span style="color: #0000cc;">PNG</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">,</span> stream<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">return</span> stream<span style="color: #333333;">.</span><span style="color: #0000cc;">toByteArray</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// convert from byte array to bitmap</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> Bitmap <span style="color: #0066bb; font-weight: bold;">getImage</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[]</span> image<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> BitmapFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">decodeByteArray</span><span style="color: #333333;">(</span>image<span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">,</span> image<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><p>Klasik bir <b>CRUD </b>(Create Read Update Delete) sayfasının ihtiyacı olan tüm metodların tanımlı olduğunu görüyoruz. </p><ul style="text-align: left;"><li>Yeni bir müşteri kaydı oluşturma</li><li>id'si verilen bir müşteri verisini okuma</li><li>Tanımlı tüm müşterileri okuma</li><li>id'si verilen bir müşteriyi silme veya verilerini güncelleme</li><li>Customer verisini imaj dosyası verisi ile veya resim verisi olmadan okuma <br /></li></ul><p>yeteneklerini bu şekilde dao sınıfımıza kazandırmış olduk. </p><p>Şimdi de bu DAO sınıfını örnek bir Activity sınıfında nasıl kullanacağımızı görelim.</p><div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.os.Bundle</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.support.v7.app.AppCompatActivity</span><span style="color: #333333;">;</span>
<span style="color: #888888;">/**</span>
<span style="color: #888888;"> * @author moksuzer</span>
<span style="color: #888888;"> * @see muratoksuzer.com</span>
<span style="color: #888888;"> */</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">ExampleActivity</span> <span style="color: #008800; font-weight: bold;">extends</span> AppCompatActivity <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> CustomerDAO dataSource<span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">protected</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onCreate</span><span style="color: #333333;">(</span>Bundle savedInstanceState<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">super</span><span style="color: #333333;">.</span><span style="color: #0000cc;">onCreate</span><span style="color: #333333;">(</span>savedInstanceState<span style="color: #333333;">);</span>
<span style="color: #888888;">//...</span>
dataSource <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> CustomerDAO<span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">);</span>
dataSource<span style="color: #333333;">.</span><span style="color: #0000cc;">open</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">protected</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onPause</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
dataSource<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">super</span><span style="color: #333333;">.</span><span style="color: #0000cc;">onPause</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">protected</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onResume</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
dataSource<span style="color: #333333;">.</span><span style="color: #0000cc;">open</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">super</span><span style="color: #333333;">.</span><span style="color: #0000cc;">onResume</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><p><b>ExampleActivity</b><b><b>.java</b> </b>sınıfımızda da görüdğümüz gibi Activity sınıfımızın Android SDK'sından gelen <b>onCreate()</b> ve <b>onResume()</b> metodlarında dataSource nesnemizi <b>open()</b> metodu ile kullanıma hazır hale getirmemiz gerekiyor. <b>onPause() </b>metodunda da fazla sistem kaynağı yememek için <b>close()</b> ile kapatmamız gerekiyor. open() çaprıldıktan sonraki durumlarda dao'da tanımladığımız metodlardan istediğimizi çağırarak uygulama mantığımızı gerçekleştirebiliriz.<br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-48875121732457658852021-05-15T03:59:00.006-07:002021-05-15T12:03:37.946-07:00Apache POI ile Java'da Excel Dosya Yazma ve Okuma<div><p>Microsoft Office dosyalarını Java'da okumak ve düzenlemek için geliştirilen <a href="https://poi.apache.org/" rel="nofollow" target="_blank">Apache POI</a> kütüphanesi ile metin, sayısal, tarih ve resim türünde verilerin nasıl xlsx uzantılı excel dosyasına yazılacağını ve okunacağını göreceğiz.</p><p><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAiw_1hV8s6N-7A7Td2fpQqJ_DetpU5RrL55Tfbn4vstONIcdQ7Q1hEhh6Cb7gRLjMYeITARID8YnG4OKetbkUqPPqWrwi_jzaWWuEdKkwNA0w9xZ8NlrdAq6tF_mUwsMqVDzZrAGYx4M/s2048/poi_excel.png" style="margin-left: auto; margin-right: auto;"><img alt="Apache POI Excel okuma Yazma" border="0" data-original-height="1365" data-original-width="2048" height="266" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAiw_1hV8s6N-7A7Td2fpQqJ_DetpU5RrL55Tfbn4vstONIcdQ7Q1hEhh6Cb7gRLjMYeITARID8YnG4OKetbkUqPPqWrwi_jzaWWuEdKkwNA0w9xZ8NlrdAq6tF_mUwsMqVDzZrAGYx4M/w400-h266/poi_excel.png" title="Apache POI Excel okuma Yazma" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Apache POI Excel okuma Yazma</td></tr></tbody></table><br /><p></p><p>Bu yazıyı yazarken son sürüm 5.0.0 idi ve <a href="https://mvnrepository.com/artifact/org.apache.poi/poi" rel="nofollow" target="_blank">şu adresten maven bağımlılığını</a> projemize ekleyerek çalışmaya başlayabiliriz.<br /></p><p>Bir ürün envanteri excel dosyası oluşturup daha sonra okuyacağız. Bunun için öncelikle aşağıdaki gibi Product.java isimli bir sınıf oluşturalım. Parasal değerler için BigDecimal kullanmak double gibi küsüratı kararsız bir yapı kullanmaktan daha iyidir.<br /></p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.math.BigDecimal</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Date</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Product</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> id<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String barcode<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String name<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String description<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> BigDecimal price<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> stock<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">double</span> remainingStockPercentage<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Date purchaseDate<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[]</span> image<span style="color: #333333;">;</span>
<span style="color: #888888;">// getters & setters</span>
<span style="color: #333333;">}</span>
</pre></div><p><b>.xlsx</b> uzantılı excel dosyası yazmak için <b>WriteInventoryExcel.java</b> isimli bir sınıf oluşturalım ve main metoduna aşağıdaki kodları ekleyelim. </p><p>Apache poi ile workbook nesnesi oluşturalım ve "Products" isimli bir sekme (sheet) oluşturalım.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">XSSFWorkbook workbook <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> XSSFWorkbook<span style="color: #333333;">();</span>
XSSFSheet sheet <span style="color: #333333;">=</span> workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">createSheet</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Products"</span><span style="color: #333333;">);</span>
</pre></div><p> Resim dosyalarını excel dosyasına yazmak için Drawing nesnesi oluşturalım.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">CreationHelper creationHelper <span style="color: #333333;">=</span> workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">getCreationHelper</span><span style="color: #333333;">();</span>
Drawing drawing <span style="color: #333333;">=</span> sheet<span style="color: #333333;">.</span><span style="color: #0000cc;">createDrawingPatriarch</span><span style="color: #333333;">();</span>
</pre></div><p> Örnek olması için 2 adet Product nesnesi oluşturalım ve içeriğini dolduralım.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">Product deneyapKart <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Product<span style="color: #333333;">();</span>
deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">setId</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">);</span>
deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">setBarcode</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"111222333445566"</span><span style="color: #333333;">);</span>
deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">setName</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Deneyap Kart"</span><span style="color: #333333;">);</span>
deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">setDescription</span><span style="color: #333333;">(</span>
<span style="background-color: #fff0f0;">"Ülkemizin mühendislik kaynakları kullanılarak geliştirilen Deneyap Kart; güçlü işlemcisi,"</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" dayanıklı tasarımı ve çok yönlü giriş/çıkış pinleri ile Elektronik Programlama,"</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" Nesnelerin İnterneti (IoT) ve Yapay Zeka alanlarında başlangıç için ideal bir karttır."</span><span style="color: #333333;">);</span>
deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">setPrice</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> BigDecimal<span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"139.99"</span><span style="color: #333333;">));</span>
deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">setPurchaseDate</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Date<span style="color: #333333;">());</span>
deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">setRemainingStockPercentage</span><span style="color: #333333;">(</span><span style="color: #6600ee; font-weight: bold;">0.85</span><span style="color: #333333;">);</span>
deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">setStock</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1581</span><span style="color: #333333;">);</span>
<span style="color: #888888;">// read image</span>
FileInputStream stream <span style="color: #333333;">=</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">FileInputStream</span><span style="color: #333333;">(</span> <span style="background-color: #fff0f0;">"Dene_yap_089.jpg"</span> <span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[]</span> image <span style="color: #333333;">=</span> IOUtils<span style="color: #333333;">.</span><span style="color: #0000cc;">toByteArray</span><span style="color: #333333;">(</span>stream<span style="color: #333333;">);</span>
deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">setImage</span><span style="color: #333333;">(</span>image<span style="color: #333333;">);</span>
Product xiaomiRedmi <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Product<span style="color: #333333;">();</span>
xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">setId</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">);</span>
xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">setName</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Xiaomi Redmi Note 10 64GB (Xiaomi Türkiye Garantili)"</span><span style="color: #333333;">);</span>
xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">setDescription</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Xiaomi Redmi Note 10 64GB, Android işletim sistemli telefonlar arasında "</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"kendine ayrı bir yer buluyor."</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" Çerçevesiz formdaki ürün, ağırlığının azalması ve konforlu kullanım için özel"</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" polikarbon materyal kasasıyla geliyor. Xiaomi Redmi Note 10 64GB "</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"işletim sistemi olarak Android 11 ile gelirken arayüzü ise"</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" Xiaomi imzası taşıyan MIUI 12 olarak sahiplerinin karşısına çıkıyor."</span><span style="color: #333333;">);</span>
xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">setBarcode</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"HBCV0000027FN6"</span><span style="color: #333333;">);</span>
xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">setPrice</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> BigDecimal<span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"2849.90"</span><span style="color: #333333;">));</span>
xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">setPurchaseDate</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Date<span style="color: #333333;">());</span>
xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">setStock</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">251</span><span style="color: #333333;">);</span>
xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">setRemainingStockPercentage</span><span style="color: #333333;">(</span><span style="color: #6600ee; font-weight: bold;">0.53</span><span style="color: #333333;">);</span>
stream <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> FileInputStream<span style="color: #333333;">(</span> <span style="background-color: #fff0f0;">"xiaomi-redmi-note-10-64-gb-z.jpg"</span> <span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[]</span> xiaomiImage <span style="color: #333333;">=</span> IOUtils<span style="color: #333333;">.</span><span style="color: #0000cc;">toByteArray</span><span style="color: #333333;">(</span>stream<span style="color: #333333;">);</span>
xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">setImage</span><span style="color: #333333;">(</span>xiaomiImage<span style="color: #333333;">);</span>
</pre></div><p>Kodda görüldüğü gibi resim dosyalarını byte array olarak okuduğumuzu not edelim.</p><h3 style="text-align: left;">Apache POI ile Hücrelere Stil (Style) Uygulama<br /></h3><p>Excel dosyamızda ilk satırı başlık satırı olarak kullanacağız. Kolonların başlıklarını kalın stilde <b>(bold) </b>ekleyeceğiz. Bu sayede hücrelere stil (style) uygulamayı da görmüş olacağız.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #333399; font-weight: bold;">int</span> rowCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
XSSFRow titleRow <span style="color: #333333;">=</span> sheet<span style="color: #333333;">.</span><span style="color: #0000cc;">createRow</span><span style="color: #333333;">(</span>rowCount<span style="color: #333333;">++);</span>
<span style="color: #333399; font-weight: bold;">int</span> columnCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
CellStyle boldStyle <span style="color: #333333;">=</span> workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">createCellStyle</span><span style="color: #333333;">();</span>
Font font <span style="color: #333333;">=</span> workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">createFont</span><span style="color: #333333;">();</span>
font<span style="color: #333333;">.</span><span style="color: #0000cc;">setBold</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">true</span><span style="color: #333333;">);</span>
boldStyle<span style="color: #333333;">.</span><span style="color: #0000cc;">setFont</span><span style="color: #333333;">(</span>font<span style="color: #333333;">);</span>
XSSFCell cell1 <span style="color: #333333;">=</span> titleRow<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell1<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"ID"</span><span style="color: #333333;">);</span>
cell1<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellStyle</span><span style="color: #333333;">(</span>boldStyle<span style="color: #333333;">);</span>
XSSFCell cell2 <span style="color: #333333;">=</span> titleRow<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell2<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Ürün Adı"</span><span style="color: #333333;">);</span>
cell2<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellStyle</span><span style="color: #333333;">(</span>boldStyle<span style="color: #333333;">);</span>
XSSFCell cell3 <span style="color: #333333;">=</span> titleRow<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell3<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Açıklama"</span><span style="color: #333333;">);</span>
cell3<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellStyle</span><span style="color: #333333;">(</span>boldStyle<span style="color: #333333;">);</span>
XSSFCell cell4 <span style="color: #333333;">=</span> titleRow<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell4<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Barkod"</span><span style="color: #333333;">);</span>
cell4<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellStyle</span><span style="color: #333333;">(</span>boldStyle<span style="color: #333333;">);</span>
XSSFCell cell5 <span style="color: #333333;">=</span> titleRow<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell5<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Fiyat"</span><span style="color: #333333;">);</span>
cell5<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellStyle</span><span style="color: #333333;">(</span>boldStyle<span style="color: #333333;">);</span>
XSSFCell cell6 <span style="color: #333333;">=</span> titleRow<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell6<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Tarih"</span><span style="color: #333333;">);</span>
cell6<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellStyle</span><span style="color: #333333;">(</span>boldStyle<span style="color: #333333;">);</span>
XSSFCell cell7 <span style="color: #333333;">=</span> titleRow<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell7<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Stok"</span><span style="color: #333333;">);</span>
cell7<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellStyle</span><span style="color: #333333;">(</span>boldStyle<span style="color: #333333;">);</span>
XSSFCell cell8 <span style="color: #333333;">=</span> titleRow<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell8<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Kalan Stok Yüzdesi"</span><span style="color: #333333;">);</span>
cell8<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellStyle</span><span style="color: #333333;">(</span>boldStyle<span style="color: #333333;">);</span>
XSSFCell cell9 <span style="color: #333333;">=</span> titleRow<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell9<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Resim"</span><span style="color: #333333;">);</span>
cell9<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellStyle</span><span style="color: #333333;">(</span>boldStyle<span style="color: #333333;">);</span>
</pre></div><h3 style="text-align: left;">Apache POI ile Excel Dosyasına Resim Dosyası Ekleme<br /></h3><p>Şimdi de örnek olarak oluşturduğumuz Deneyapkart nesnesini excel ürün envanteri dosyamıza bir satır olarak ekleyelim. Tarih verisini SimpleDateFormat ile formatlanmış bir String'e çevirip metin olarak kaydediyoruz. Düz Date nesnesi olarak da yazılabilirdik fakat o zaman long türünde timestamp değerini yazdıracaktı ve dosyayı açtığımızda uzun bir sayı görecek ve tarih değeri olduğu anlaşılmayacaktı.<br /></p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">XSSFRow row1 <span style="color: #333333;">=</span> sheet<span style="color: #333333;">.</span><span style="color: #0000cc;">createRow</span><span style="color: #333333;">(</span>rowCount<span style="color: #333333;">++);</span>
columnCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
cell1 <span style="color: #333333;">=</span> row1<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell1<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">getId</span><span style="color: #333333;">());</span>
cell2 <span style="color: #333333;">=</span> row1<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell2<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">getName</span><span style="color: #333333;">());</span>
cell3 <span style="color: #333333;">=</span> row1<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell3<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">getDescription</span><span style="color: #333333;">());</span>
cell4 <span style="color: #333333;">=</span> row1<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell4<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">getBarcode</span><span style="color: #333333;">());</span>
cell5 <span style="color: #333333;">=</span> row1<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell5<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">getPrice</span><span style="color: #333333;">().</span><span style="color: #0000cc;">doubleValue</span><span style="color: #333333;">());</span>
SimpleDateFormat dateFormat <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> SimpleDateFormat<span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"dd/MM/yyyy"</span><span style="color: #333333;">);</span>
cell6 <span style="color: #333333;">=</span> row1<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell6<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>dateFormat<span style="color: #333333;">.</span><span style="color: #0000cc;">format</span><span style="color: #333333;">(</span>deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">getPurchaseDate</span><span style="color: #333333;">()));</span>
cell7 <span style="color: #333333;">=</span> row1<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell7<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">getStock</span><span style="color: #333333;">());</span>
cell8 <span style="color: #333333;">=</span> row1<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell8<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">getRemainingStockPercentage</span><span style="color: #333333;">());</span>
ClientAnchor anchor <span style="color: #333333;">=</span> creationHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">createClientAnchor</span><span style="color: #333333;">();</span>
anchor<span style="color: #333333;">.</span><span style="color: #0000cc;">setAnchorType</span><span style="color: #333333;">(</span>ClientAnchor<span style="color: #333333;">.</span><span style="color: #0000cc;">AnchorType</span><span style="color: #333333;">.</span><span style="color: #0000cc;">MOVE_AND_RESIZE</span> <span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">int</span> pictureIndex <span style="color: #333333;">=</span>
workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">addPicture</span><span style="color: #333333;">(</span>deneyapKart<span style="color: #333333;">.</span><span style="color: #0000cc;">getImage</span><span style="color: #333333;">(),</span> Workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">PICTURE_TYPE_JPEG</span><span style="color: #333333;">);</span>
anchor<span style="color: #333333;">.</span><span style="color: #0000cc;">setCol1</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
anchor<span style="color: #333333;">.</span><span style="color: #0000cc;">setRow1</span><span style="color: #333333;">(</span> <span style="color: #0000dd; font-weight: bold;">1</span> <span style="color: #333333;">);</span>
anchor<span style="color: #333333;">.</span><span style="color: #0000cc;">setRow2</span><span style="color: #333333;">(</span> <span style="color: #0000dd; font-weight: bold;">2</span> <span style="color: #333333;">);</span>
anchor<span style="color: #333333;">.</span><span style="color: #0000cc;">setCol2</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
Picture pict <span style="color: #333333;">=</span> drawing<span style="color: #333333;">.</span><span style="color: #0000cc;">createPicture</span><span style="color: #333333;">(</span> anchor<span style="color: #333333;">,</span> pictureIndex <span style="color: #333333;">);</span>
pict<span style="color: #333333;">.</span><span style="color: #0000cc;">resize</span><span style="color: #333333;">();</span>
</pre></div><p>Resim dosyasını yazmak için ClientAnchor nesnesini kullanarak ve drawing nesnesi ile Picture nesnesi<br /></p><p>oluşturduğumuzu not edelim.</p><p>Benzer şekilde xiaomiRedmi nesnesini de 2. satır olarak yazdıralım.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">XSSFRow row2 <span style="color: #333333;">=</span> sheet<span style="color: #333333;">.</span><span style="color: #0000cc;">createRow</span><span style="color: #333333;">(</span>rowCount<span style="color: #333333;">++);</span>
columnCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
cell1 <span style="color: #333333;">=</span> row2<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell1<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">getId</span><span style="color: #333333;">());</span>
cell2 <span style="color: #333333;">=</span> row2<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell2<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">getName</span><span style="color: #333333;">());</span>
cell3 <span style="color: #333333;">=</span> row2<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell3<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">getDescription</span><span style="color: #333333;">());</span>
cell4 <span style="color: #333333;">=</span> row2<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell4<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">getBarcode</span><span style="color: #333333;">());</span>
cell5 <span style="color: #333333;">=</span> row2<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell5<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">getPrice</span><span style="color: #333333;">().</span><span style="color: #0000cc;">doubleValue</span><span style="color: #333333;">());</span>
cell6 <span style="color: #333333;">=</span> row2<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell6<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>dateFormat<span style="color: #333333;">.</span><span style="color: #0000cc;">format</span><span style="color: #333333;">(</span>xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">getPurchaseDate</span><span style="color: #333333;">()));</span>
cell7 <span style="color: #333333;">=</span> row2<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell7<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">getStock</span><span style="color: #333333;">());</span>
cell8 <span style="color: #333333;">=</span> row2<span style="color: #333333;">.</span><span style="color: #0000cc;">createCell</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
cell8<span style="color: #333333;">.</span><span style="color: #0000cc;">setCellValue</span><span style="color: #333333;">(</span>xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">getRemainingStockPercentage</span><span style="color: #333333;">());</span>
anchor <span style="color: #333333;">=</span> creationHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">createClientAnchor</span><span style="color: #333333;">();</span>
anchor<span style="color: #333333;">.</span><span style="color: #0000cc;">setAnchorType</span><span style="color: #333333;">(</span>ClientAnchor<span style="color: #333333;">.</span><span style="color: #0000cc;">AnchorType</span><span style="color: #333333;">.</span><span style="color: #0000cc;">MOVE_AND_RESIZE</span> <span style="color: #333333;">);</span>
stream <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> FileInputStream<span style="color: #333333;">(</span> <span style="background-color: #fff0f0;">"xiaomi-redmi-note-10-64-gb-z.jpg"</span> <span style="color: #333333;">);</span>
pictureIndex <span style="color: #333333;">=</span> workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">addPicture</span><span style="color: #333333;">(</span>xiaomiRedmi<span style="color: #333333;">.</span><span style="color: #0000cc;">getImage</span><span style="color: #333333;">(),</span> Workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">PICTURE_TYPE_JPEG</span><span style="color: #333333;">);</span>
anchor<span style="color: #333333;">.</span><span style="color: #0000cc;">setCol1</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
anchor<span style="color: #333333;">.</span><span style="color: #0000cc;">setRow1</span><span style="color: #333333;">(</span> <span style="color: #0000dd; font-weight: bold;">2</span> <span style="color: #333333;">);</span>
anchor<span style="color: #333333;">.</span><span style="color: #0000cc;">setRow2</span><span style="color: #333333;">(</span> <span style="color: #0000dd; font-weight: bold;">3</span> <span style="color: #333333;">);</span>
anchor<span style="color: #333333;">.</span><span style="color: #0000cc;">setCol2</span><span style="color: #333333;">(</span>columnCount<span style="color: #333333;">++);</span>
pict <span style="color: #333333;">=</span> drawing<span style="color: #333333;">.</span><span style="color: #0000cc;">createPicture</span><span style="color: #333333;">(</span> anchor<span style="color: #333333;">,</span> pictureIndex <span style="color: #333333;">);</span>
pict<span style="color: #333333;">.</span><span style="color: #0000cc;">resize</span><span style="color: #333333;">();</span>
</pre></div><p>Ekleyeceğimiz satırlar tamamlandığında son adım olarak oluşturduğumuz workbook nesnesini <b>inventory.xlsx</b> isimli bir excel dosyasına yazdıralım.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">(</span>FileOutputStream outputStream <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> FileOutputStream<span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"inventory.xlsx"</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">write</span><span style="color: #333333;">(</span>outputStream<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
</pre></div><p>Şimdi <b>WriteInventoryExcel.java </b>sınıfını çalıştıralım. Sonuç olarak içeriği aşağıdaki gibi olan inventory.xlsx isimli bir dosya oluşacaktır.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiA1tsktZWEd97sT8qai2nnmpXA0cmeRfM38P0MNASXl1uW6UQQCLzilRqRhSyBmxCZIMy9U3jRyaDy1IOJ5hTILWaP8zuQjjnjtcZ0Axh0yGvXaCYi9RYA4BQTI7i1WcYu2Kp96_wogOs/s838/inventory_xlsx.PNG" style="margin-left: 1em; margin-right: 1em;"><img alt="inventory.xlsx" border="0" data-original-height="610" data-original-width="838" height="291" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiA1tsktZWEd97sT8qai2nnmpXA0cmeRfM38P0MNASXl1uW6UQQCLzilRqRhSyBmxCZIMy9U3jRyaDy1IOJ5hTILWaP8zuQjjnjtcZ0Axh0yGvXaCYi9RYA4BQTI7i1WcYu2Kp96_wogOs/w400-h291/inventory_xlsx.PNG" title="inventory.xlsx" width="400" /></a></div><br /></div><h3 style="text-align: left;">Apache POI ile xlsx Uzantılı Excel Dosyası Okuma</h3><p>Şimdi de yazmış olduğumuz inventory.xlsx dosyasını Apache POI kütüphanesi ile okuyalım.</p><p><b>ReadInventoryExcel.java</b> isimli bir sınıf oluşturalım ve main metoduna aşağıdaki kodları ekleyelim.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">Workbook workbook <span style="color: #333333;">=</span> WorkbookFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">create</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> File<span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"inventory.xlsx"</span><span style="color: #333333;">));</span>
Iterator<span style="color: #333333;"><</span>Sheet<span style="color: #333333;">></span> sheetIterator <span style="color: #333333;">=</span> workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">sheetIterator</span><span style="color: #333333;">();</span>
Sheet productSheet <span style="color: #333333;">=</span> sheetIterator<span style="color: #333333;">.</span><span style="color: #0000cc;">next</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"sheet name: "</span> <span style="color: #333333;">+</span> productSheet<span style="color: #333333;">.</span><span style="color: #0000cc;">getSheetName</span><span style="color: #333333;">());</span>
Iterator<span style="color: #333333;"><</span>Row<span style="color: #333333;">></span> rowIterator <span style="color: #333333;">=</span> productSheet<span style="color: #333333;">.</span><span style="color: #0000cc;">rowIterator</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(</span>rowIterator<span style="color: #333333;">.</span><span style="color: #0000cc;">hasNext</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
Row row <span style="color: #333333;">=</span> rowIterator<span style="color: #333333;">.</span><span style="color: #0000cc;">next</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>row<span style="color: #333333;">.</span><span style="color: #0000cc;">getRowNum</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// baslik satirini atla</span>
<span style="color: #008800; font-weight: bold;">continue</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
Cell cell1 <span style="color: #333333;">=</span> row<span style="color: #333333;">.</span><span style="color: #0000cc;">getCell</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">);</span>
Integer id <span style="color: #333333;">=</span> Integer<span style="color: #333333;">.</span><span style="color: #0000cc;">valueOf</span><span style="color: #333333;">((</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span> cell1<span style="color: #333333;">.</span><span style="color: #0000cc;">getNumericCellValue</span><span style="color: #333333;">());</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"id: "</span> <span style="color: #333333;">+</span> id<span style="color: #333333;">);</span>
Cell cell2 <span style="color: #333333;">=</span> row<span style="color: #333333;">.</span><span style="color: #0000cc;">getCell</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">);</span>
String name <span style="color: #333333;">=</span> cell2<span style="color: #333333;">.</span><span style="color: #0000cc;">getStringCellValue</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"name: "</span> <span style="color: #333333;">+</span> name<span style="color: #333333;">);</span>
Cell cell3 <span style="color: #333333;">=</span> row<span style="color: #333333;">.</span><span style="color: #0000cc;">getCell</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">);</span>
String description <span style="color: #333333;">=</span> cell3<span style="color: #333333;">.</span><span style="color: #0000cc;">getStringCellValue</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"description: "</span> <span style="color: #333333;">+</span> description<span style="color: #333333;">);</span>
Cell cell4 <span style="color: #333333;">=</span> row<span style="color: #333333;">.</span><span style="color: #0000cc;">getCell</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">);</span>
String barcode <span style="color: #333333;">=</span> cell4<span style="color: #333333;">.</span><span style="color: #0000cc;">getStringCellValue</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"barcode: "</span> <span style="color: #333333;">+</span> barcode<span style="color: #333333;">);</span>
Cell cell5 <span style="color: #333333;">=</span> row<span style="color: #333333;">.</span><span style="color: #0000cc;">getCell</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">);</span>
BigDecimal price <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> BigDecimal<span style="color: #333333;">(</span>cell5<span style="color: #333333;">.</span><span style="color: #0000cc;">getNumericCellValue</span><span style="color: #333333;">());</span>
price <span style="color: #333333;">=</span> price<span style="color: #333333;">.</span><span style="color: #0000cc;">setScale</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">,</span> BigDecimal<span style="color: #333333;">.</span><span style="color: #0000cc;">ROUND_HALF_UP</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"price: "</span> <span style="color: #333333;">+</span> price<span style="color: #333333;">);</span>
SimpleDateFormat dateFormat <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> SimpleDateFormat<span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"dd/MM/yyyy"</span><span style="color: #333333;">);</span>
Cell cell6 <span style="color: #333333;">=</span> row<span style="color: #333333;">.</span><span style="color: #0000cc;">getCell</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">);</span>
String dateString <span style="color: #333333;">=</span> cell6<span style="color: #333333;">.</span><span style="color: #0000cc;">getStringCellValue</span><span style="color: #333333;">();</span>
Date purchaseDate <span style="color: #333333;">=</span> dateFormat<span style="color: #333333;">.</span><span style="color: #0000cc;">parse</span><span style="color: #333333;">(</span>dateString<span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"purchase date: "</span> <span style="color: #333333;">+</span> purchaseDate<span style="color: #333333;">);</span>
Cell cell7 <span style="color: #333333;">=</span> row<span style="color: #333333;">.</span><span style="color: #0000cc;">getCell</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">6</span><span style="color: #333333;">);</span>
Integer stock <span style="color: #333333;">=</span> Integer<span style="color: #333333;">.</span><span style="color: #0000cc;">valueOf</span><span style="color: #333333;">((</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span> cell7<span style="color: #333333;">.</span><span style="color: #0000cc;">getNumericCellValue</span><span style="color: #333333;">());</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"stock: "</span> <span style="color: #333333;">+</span> stock<span style="color: #333333;">);</span>
Cell cell8 <span style="color: #333333;">=</span> row<span style="color: #333333;">.</span><span style="color: #0000cc;">getCell</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">7</span><span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> remainingStockPercantage <span style="color: #333333;">=</span> cell8<span style="color: #333333;">.</span><span style="color: #0000cc;">getNumericCellValue</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"remaining stock percantage: "</span> <span style="color: #333333;">+</span> remainingStockPercantage<span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
</pre></div><p>Date bilgisini yazdığımız formatın aynısı ile okuyup parse ediyoruz. Parasal fiyat bilgisini de BigDecimal'a çevirip noktadan sonraki sadece 2 basamağı kullanmasını istiyoruz.<br /><b></b></p><h3 style="text-align: left;">Apache POI ile Excel Dosyasından Resim Okuma</h3><p style="text-align: left;">Bir önceki bölümde dosyaya eklediğimi JPG türündeki dosyaları okuyup yine dosyaya farklı isimlerde yazdıralım.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">List allPictures <span style="color: #333333;">=</span> workbook<span style="color: #333333;">.</span><span style="color: #0000cc;">getAllPictures</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span>Iterator it <span style="color: #333333;">=</span> allPictures<span style="color: #333333;">.</span><span style="color: #0000cc;">iterator</span><span style="color: #333333;">();</span> it<span style="color: #333333;">.</span><span style="color: #0000cc;">hasNext</span><span style="color: #333333;">();</span> <span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
PictureData picture <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>PictureData<span style="color: #333333;">)</span>it<span style="color: #333333;">.</span><span style="color: #0000cc;">next</span><span style="color: #333333;">();</span>
String extension <span style="color: #333333;">=</span> picture<span style="color: #333333;">.</span><span style="color: #0000cc;">suggestFileExtension</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[]</span> data <span style="color: #333333;">=</span> picture<span style="color: #333333;">.</span><span style="color: #0000cc;">getData</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>extension<span style="color: #333333;">.</span><span style="color: #0000cc;">equals</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"jpeg"</span><span style="color: #333333;">)){</span>
FileOutputStream out <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> FileOutputStream<span style="color: #333333;">(</span>i<span style="color: #333333;">++</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"_picture.jpg"</span><span style="color: #333333;">);</span>
out<span style="color: #333333;">.</span><span style="color: #0000cc;">write</span><span style="color: #333333;">(</span>data<span style="color: #333333;">);</span>
out<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><p>Oluşturduğumuz bu <b>ReadInventoryExcel.java </b>sınıfını çalıştırdığımızda konsolda satır bilgilerini göreceğiz ve 1_picture.jpg ve2_picture.jpg isimli dosyaların oluştuğunu göreceğiz.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-1035129599429426802021-05-12T04:00:00.000-07:002021-05-12T04:00:06.586-07:00Blogger Özel Tema Uygulama ve Code Highlighting<div><p>Bu yazımda blogger altyapısını kullanan sitelerde özel tema uygulama ve yazılarda paylaşılan kodların güzel ve okunur görünmesi için nasıl code highlighting yapıldığından bahsedeceğim.</p><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBbZkH0-YcbU_vjc7R3plwnVvR9WKsTzZ0oECohffApdnc_uSF5gt2I6DOkE1W3D8eB1ktBpHl-rBdBLKbN4Y233_LQq-ZpfSMHt5qHRLMv4NpOSBZZlnFboQmSO-Y3NntUfXmpmixNd4/s775/blogger-tema-uygulama-1.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Yazılım Blogu Blogger Tema Uygulama" border="0" data-original-height="422" data-original-width="775" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBbZkH0-YcbU_vjc7R3plwnVvR9WKsTzZ0oECohffApdnc_uSF5gt2I6DOkE1W3D8eB1ktBpHl-rBdBLKbN4Y233_LQq-ZpfSMHt5qHRLMv4NpOSBZZlnFboQmSO-Y3NntUfXmpmixNd4/w400-h217/blogger-tema-uygulama-1.PNG" title="Yazılım Blogu Blogger Tema Uygulama" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Yazılım Blogu Blogger Tema Uygulama <br /></td></tr></tbody></table><br /> <p></p><p><br /></p><h2 style="text-align: left;">Neden Özel Tema Uyguladım?<br /></h2><p>Blog altyapısı olarak Blogger (Blogspot) kullanıyorum. Blogger'ın kendi temalarından birini kullanıyordum. Bu ön tanımlı temaları ne kadar özelleştirmeye çalışsam da modern bir görüntü kazanmadı. 90'ların siteleri gibi görünüyordu. Göze daha hoş gelmesi ve daha kullanışlı olması için özel tema uygulama arayışına giriştim. </p><h2 style="text-align: left;">Ücretsiz Blogger Tema Siteleri</h2><p>Aşağıdaki sitelerden üzretsiz temalar indirebiliyorsunuz. Ücretsiz olmasının karşılığı genelde premium bazı özelliklerden fedakarlık ve sitede temanın kendi copyright linkinin bulunması oluyor. Ufak bir meblağ ödeyerek de premium özelliklere sahip olabilirsiniz.<br /></p><ul style="text-align: left;"><li><a href="https://gooyaabitemplates.com/" rel="nofollow" target="_blank">Gooyaabi Templates </a></li><li><a href="https://btemplates.com" rel="nofollow" target="_blank">BTemplates </a></li><li><a href="https://www.templatesyard.com/" rel="nofollow" target="_blank">Templatesyard</a> <br /></li></ul><h2 style="text-align: left;"> </h2><h2 style="text-align: left;">Blogger Tema Nasıl Uygulanır?</h2><p style="text-align: left;">Blogger yönetim panelinden Tema bölümüne geliyoruz.</p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbtrNAHKrkOPewJh8X9M9kA8btByJws_CXjhEHAnI7gzDpJJpbsZtXchyPUnZfDQuoWLY1gmRBKGj3lPzJKMd8dNRkMy2uRwv859uBrTzrdJSderq_M3RVJFQgwHdVHtXKZ0xfXV8QVcE/s931/tema-uygulama-1.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Blogger Tema Uygulama" border="0" data-original-height="509" data-original-width="931" height="219" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbtrNAHKrkOPewJh8X9M9kA8btByJws_CXjhEHAnI7gzDpJJpbsZtXchyPUnZfDQuoWLY1gmRBKGj3lPzJKMd8dNRkMy2uRwv859uBrTzrdJSderq_M3RVJFQgwHdVHtXKZ0xfXV8QVcE/w400-h219/tema-uygulama-1.PNG" title="Blogger Tema Uygulama" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Blogger Tema Uygulama <br /></td></tr></tbody></table><br /></div><p style="text-align: left;">Buradaki menüden öncelikle <b>"Yedekle" </b>diyerek orijinal temamızı indirip yedekliyoruz. Herhangi bir sebeple eski temaya dönmek isteyebiliriz. Daha sonra <b>"Geri Yükle"</b> diyerek indirdiğimiz tema klasöründen çıkan XML dosyasını seçiyoruz.</p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9VvFdAi5gsROIN1jXM9sstpNdRtfi8DB8KtNYxlH0orwp7ywaUrpltqTI09hS_OG1rYpK6QManG4_rn_0JGTgkU3E09N5c3Zsw28rJucpS4dmq3aGss01JxHmJldtWEKALIprtkskKVU/s791/tema-uygulama-2.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Blogger Tema Uygulama / Geri Yükle" border="0" data-original-height="474" data-original-width="791" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9VvFdAi5gsROIN1jXM9sstpNdRtfi8DB8KtNYxlH0orwp7ywaUrpltqTI09hS_OG1rYpK6QManG4_rn_0JGTgkU3E09N5c3Zsw28rJucpS4dmq3aGss01JxHmJldtWEKALIprtkskKVU/w400-h240/tema-uygulama-2.PNG" title="Blogger Tema Uygulama / Geri Yükle" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Blogger Tema Uygulama / Geri Yükle</td></tr></tbody></table><h2 style="text-align: left;"> </h2><h2 style="text-align: left;">Yazılım Bloglarının Olmazsa Olmazı: Kod<br /></h2><p>Aradığım kıstaslardan biri de yazılarımda paylaştığım kod örneklerinin güzel formatlanmış bir şekilde görünebilmesi idi. Bunun için çok çeşitli yollar bulunmakta. Örneğin, GitHub'da Gist olarak paylaşma ve yazı içine gömme. Yalnız bu şekilde kodlar 3. parti bir sitede bulunacağından arama motoru indekslemelerinde kodların görünmeyeceğinden endişe ettim. Bu nedenle kodların direk yazı içinden sunulması için<a href="http://hilite.me/" rel="nofollow" target="_blank"> http://hilite.me/ </a>sitesini kullanmaya başladım. Bu sitede kodunuzu yapıştırıyorsunuz ve size css ile güzelce formatlanmış bir html veriyor. Bu html'i de direk yazı içine kopyalayabiliyorsunuz. Belki daha kolay yöntemler vardır ama benim Blogger altyapılı siteler için bulabildiğim en kolay yol bu şekilde oldu. Wordpress siteler için farklı pluginler de mevcut. Aşağıdaki <a href="http://hilite.me/">hilite.me</a> ile ürettiğim bir code highlighting örneğini inceleyelim.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #888888;">// Your First C++ Program</span>
<span style="color: #557799;">#include <iostream></span>
<span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">main</span>() {
std<span style="color: #333333;">::</span>cout <span style="color: #333333;"><<</span> <span style="background-color: #fff0f0;">"Hello World!"</span>;
std<span style="color: #333333;">::</span>cout <span style="color: #333333;"><<</span> <span style="background-color: #fff0f0;">"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."</span>;
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0000dd; font-weight: bold;">0</span>;
}
</pre></div><p><br /></p><p>Satır uzun olduğunda yatay scroll bar çıkması önemli. Syntax keywordlerinin de farklı renklerle vurgulanması sayesinde kod okunur hale geliyor.</p><h2 style="text-align: left;">Özel Blogger Teması ve Code Highlighting Problemi</h2><p>İndirdiğim özel temaları denediğimde yazılarımdaki kodlarla ilgili bir problemle karşılaştım. Renklendirme berbat hale gelmişti ve yatay scroll bar çıkmıyordu. </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihOaZ4dAiba8lXI38dKA1qZfh3OE9Q23w4hR-oFlStAH3yVsv5RhYYnYRuHdPH2zwzt1Bm6oQctF2pNh9YwMW8YkIrBZiruwQtZVreFeMwBuJUyXa6qKw2UvM2lVPghQpiZTbT9OHzGm0/s751/bozuk-highlighting.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Bozuk Code Highlighting" border="0" data-original-height="639" data-original-width="751" height="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihOaZ4dAiba8lXI38dKA1qZfh3OE9Q23w4hR-oFlStAH3yVsv5RhYYnYRuHdPH2zwzt1Bm6oQctF2pNh9YwMW8YkIrBZiruwQtZVreFeMwBuJUyXa6qKw2UvM2lVPghQpiZTbT9OHzGm0/w400-h340/bozuk-highlighting.PNG" title="Bozuk Code Highlighting" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Bozuk Code Highlighting</td></tr></tbody></table><p> </p><p>Başka başka temalar indirip denedim fakat hemen hemen hepsinde benzer sıkıntıyla karşılaştım. Sonunda iş başa düştü deyip tema dosyasına el atıp sorunun kaynağını aradım.</p><p>Tema içerisinde <b><pre> </b>tag'i için custom bir <b>CSS style</b> tanımlandığını gördüm ve benim <b>hilite.me </b>sitesinde ürettiğim HTML'deki CSS'leri ezdiğini farkettim. Bu nedenle özel tema XML dosyası içindeki bu pre tag'i style tanımı içinde aşağıdaki attribute'leri sildim ve sorun çözüldü:</p><ul style="text-align: left;"><li>background-color</li><li>background-image</li><li>color</li><li>overflow</li></ul><p>Bu sayede blog sitemi kod paylaştığım yazılarda bir bozulma olmadan yeni custom bir temaya geçirebildim.<br /></p><h2 style="text-align: left;">Yeni Temanın Site Trafiğine Etkisi</h2><p>Henüz temayı değiştireli çok olmadı fakat siteye gelen organik trafik pek değişmese de sayfa görüntüleme sayısının iki katına çıktığını söyleyebilirim. Bunda yeni temanın daha kullanışlı olması ve site içeriğini kullanıcıya daha ulaşılır kılmasının etkisi büyük.<br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-38449663352471258782021-04-30T15:24:00.012-07:002021-04-30T23:44:42.404-07:00Java PriorityQueue Kullanımı - Mars Savunma Örneği<h2 style="text-align: left;"><b><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYvgSJNS5CKuD17aO4PiR5cAFJ6Xo3PcVE4m1OjaaoDwK7kbI_r2Ikk-GHI-S1qHzQAuNUNx_I85zuzT4LzBC6klTyc3m_EkP-oZK3iwm2uxs7KOa4McQH0xmn6pn2bZEu4HGKxc1mG9M/s958/mars-tua-priorityqueue.jpg" style="margin-left: auto; margin-right: auto;"><img alt="Mars TUA - Java PriorityQueue Kullanımı" border="0" data-original-height="539" data-original-width="958" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYvgSJNS5CKuD17aO4PiR5cAFJ6Xo3PcVE4m1OjaaoDwK7kbI_r2Ikk-GHI-S1qHzQAuNUNx_I85zuzT4LzBC6klTyc3m_EkP-oZK3iwm2uxs7KOa4McQH0xmn6pn2bZEu4HGKxc1mG9M/w400-h225/mars-tua-priorityqueue.jpg" title="Mars TUA - Java PriorityQueue Kullanımı" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Mars TUA - Java PriorityQueue Kullanımı</td></tr></tbody></table><br /></b></h2><h2 style="text-align: left;"><b>PriorityQueue Nedir? <br /></b></h2><p><b>Bir Java Collections Framework üyesi olan PriorityQueue, içerdiği elemanları öncelik sırasına göre sıralayan bir kuyruk (Queue) aracıdır.</b></p><p><b>Bu yazımızda Java'da Priority Queue yapısını inceleyeceğiz.<br /></b></p><p>Normalde kuyruklar (Queue) <b>First-in-First-Out</b> yani ilk giren ilk çıkar mantığıyla çalışır. Ama bazen, bazı elemanların diğerlerine nazaran daha ehemmiyetli olduğu ve daha önce işleme sokulması gerektiği durumlar olabilir. Örneğin, bir toplulukta aşı olacak bir sonraki kişi seçilirken sıraya ilk gireni değil de yaşı en ileride olan kişiyi seçmek isteyebiliriz. Bu gibi durumlarda PriorityQueue sınıfını kullanabiliriz.</p><h2 style="text-align: left;">PriorityQueue Nasıl Sıralar? <br /></h2><p><b>java.util.PriorityQueue</b> sınıfı içerdiği nesneleri doğal sırasına göre sıralar. Ayrıca istenirse bir <b>Comparable </b>nesnesi de verilerek sıralama özelleştirilebilir. Nesneleri sıralama mantığıyla çalıştığı için null eleman veya sıralanamayan (Non-Comparable) eleman eklenmesine izin vermez.</p><h2 style="text-align: left;">PriorityQueue ile En Öncelikli Elemana Nasıl Ulaşılır?</h2><p style="text-align: left;">PriorityQueue kuyruğunun en başındaki eleman en öncelikli elemandır. Bu elemana <b>peek(), element(), poll() veya remove()</b> metodları ile ulaşabiliriz.<br /></p><p><b>peek()</b> ve <b>element() </b>metodları ile kuyruğun başındaki elemana kuyruktan silinmeden ulaşılır. <b>element()</b>'in <b>peek()</b>'den farkı dönecek eleman yoksa exception fırlatmasıdır.</p><p><b>poll() </b>ve <b>remove()</b> metodları ile ise, kuyuruğun başındaki elemama kuyruktan silinerek ulaşılır. <b>remove()</b> metodunun farkı, dönecek eleman yoksa exception fırlatmasıdır.</p><h2 style="text-align: left;">PriorityQueue Elemanları Nasıl Dolaşılır? (Iteration)<br /></h2><p>Bir Java Collections sınıfı olduğundan <b>iterator()</b> metodu bulunmaktadır. Yalnız, gözden kaçırırmaması gereken bir nokta: iterator() metodu ile elemanlar dolaşılırken (traverse), örneğin for each yapısı ile, dolaşılan elemanlar öncelik sırasına göre olmayabilir. PriorityQueue sınıfı iterator ile döndüğü nesnelerin sıralı dönmesini garanti etmemektedir. İlla sıralı dolaşılmak isteniyorsa <b>Arrays.sort(pq.toArray()) </b>şeklinde oluşturulacak array üzerinde dolaşılabilir.</p><h2 style="text-align: left;">PriorityQueue Thread-Safe Mi?<br /></h2><p>PriorityQueue sınıfı thread-safe değildir. Birden fazla threadin aynı anda kuyruğa nesne eklemeye veya çıkarmaya çalışması durumunda <b>java.util.ConcurrentModificationException </b>hatası fırlatılır.</p><p>Thread-safe bir PriorityQueue kullanmak gerekiyorsa <b>java.util.concurrent.PriorityBlockingQueue </b>sınıfı kullanılmalıdır.<br /><b></b></p><h2 style="text-align: left;">Mars Savunma Örneği</h2><p>Gelelim eğlenceli bölüme. Sene <b>2071</b>. <a href="https://tua.gov.tr/" target="_blank">Türkiye Uzay Ajansı (TUA)</a> ve TSK Uzay Kuvvetleri Komutanlığı Mars'ta yeni kurulan Türkiye kolonisini uzaydan gelebilecek asteroitlere karşı savunma görevi için yerleştirdiği lazer silahını denemek amacıyla tatbikat düzenliyorlar.</p><p>Sizin göreviniz lazer silahınnın, komuta merkezine yaklaşan en yakın asteroidi hedef almasını sağlamak.</p><p>Bu senaryoyu koda dökelim. Mars'a olan uzaklığını ve yaklaşma hızını tutacağımız Asteroit.java sınıfını tanımlayalım. Ayrıca 1 saniyede bir hızı kadar hareket etmesini söyleyeceğimiz <b>startComeClose </b>metodunu tanımlayalım. Bu metodda Timer kullanarak periyodik olarak kod çalıştırdık. Java'da Timer ve TimerTask kullanımını daha detaylı öğrenmek için <a href="https://www.muratoksuzer.com/2019/02/javada-timer-ve-timertask-kullanimi.html" target="_blank">şu yazıya bakabilirsiniz.</a><br /></p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.PriorityQueue</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Timer</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.TimerTask</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Asteroit</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> distanceToMars<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> speed<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> id<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Asteroit</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> id<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> distanceToMars<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> speed<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">id</span> <span style="color: #333333;">=</span> id<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">distanceToMars</span> <span style="color: #333333;">=</span> distanceToMars<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">speed</span> <span style="color: #333333;">=</span> speed<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">startComeClose</span><span style="color: #333333;">(</span>PriorityQueue<span style="color: #333333;"><</span>Asteroit<span style="color: #333333;">></span> asteroitDefencePriorityQueue<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
Timer timer <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Timer<span style="color: #333333;">();</span>
timer<span style="color: #333333;">.</span><span style="color: #0000cc;">scheduleAtFixedRate</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> TimerTask<span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">run</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
asteroitDefencePriorityQueue<span style="color: #333333;">.</span><span style="color: #0000cc;">remove</span><span style="color: #333333;">(</span>Asteroit<span style="color: #333333;">.</span><span style="color: #0000cc;">this</span><span style="color: #333333;">);</span>
distanceToMars <span style="color: #333333;">=</span> distanceToMars <span style="color: #333333;">-</span> speed<span style="color: #333333;">;</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"#astreoit "</span> <span style="color: #333333;">+</span> id <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" distance: "</span> <span style="color: #333333;">+</span> distanceToMars<span style="color: #333333;">);</span>
<span style="color: #888888;">// in order to reorder priorityqueue, the modified element should be removed and added</span>
asteroitDefencePriorityQueue<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Asteroit<span style="color: #333333;">.</span><span style="color: #0000cc;">this</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"simulasyon peek id "</span> <span style="color: #333333;">+</span> asteroitDefencePriorityQueue<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">().</span><span style="color: #0000cc;">getId</span><span style="color: #333333;">()</span> <span style="color: #333333;">+</span><span style="background-color: #fff0f0;">"\n"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">},</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">1000</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getDistanceToMars</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> distanceToMars<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setDistanceToMars</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> distanceToMars<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">distanceToMars</span> <span style="color: #333333;">=</span> distanceToMars<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getId</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> id<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><p>Şimdi örnek <b>main </b>uygulama metodumuzu yazalım. 2 adet asteroit tanımlayacağız. Biri 10000 km uzaklıkta fakat uzaklığı sabit, Mars'a yaklaşmıyor. Biri 15000 km uzaklıkta fakat saniyede 1000 km hızla yaklaşıyor.</p><p>Tanımlayacağımız PriorityQueue içine bu asteroitleri ekleyeceğiz. Her 1 saniyede bir, hareketli asteroitin uzaklığını güncelleyeceğiz. PriorityQueue kuyruğunun en başındaki, lazer silahımızın hedef alacağı Mars'a en yakın asteroit hangisi ise onun id'sini konsola yazacağız.</p><p>Çıktı olarak, bir süre hareketsiz bulunan asteroitin peek() metodu ile elde edildiğini ve en yakın olduğunu göreceğiz. Yaklaşık 6 sn sonra ise hareketli asteroitin daha yakında olduğu ve peek() metodu ile elde ettiğimiz asteroitin bu 2. eklediğimiz asteroit olduğunu göreceğiz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Comparator</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.PriorityQueue</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">QueueExample</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">main</span><span style="color: #333333;">(</span>String<span style="color: #333333;">[]</span> args<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
PriorityQueue<span style="color: #333333;"><</span>Asteroit<span style="color: #333333;">></span> asteroitDefencePriorityQueue <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> PriorityQueue<span style="color: #333333;"><>(</span><span style="color: #008800; font-weight: bold;">new</span> Comparator<span style="color: #333333;"><</span>Asteroit<span style="color: #333333;">>()</span> <span style="color: #333333;">{</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">compare</span><span style="color: #333333;">(</span>Asteroit o1<span style="color: #333333;">,</span> Asteroit o2<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> Integer<span style="color: #333333;">.</span><span style="color: #0000cc;">compare</span><span style="color: #333333;">(</span>o1<span style="color: #333333;">.</span><span style="color: #0000cc;">getDistanceToMars</span><span style="color: #333333;">(),</span> o2<span style="color: #333333;">.</span><span style="color: #0000cc;">getDistanceToMars</span><span style="color: #333333;">());</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">});</span>
Asteroit sabit <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Asteroit<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">10000</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">1000</span><span style="color: #333333;">);</span>
Asteroit hareketli <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Asteroit<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">15000</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">1000</span><span style="color: #333333;">);</span>
asteroitDefencePriorityQueue<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>sabit<span style="color: #333333;">);</span>
asteroitDefencePriorityQueue<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>hareketli<span style="color: #333333;">);</span>
hareketli<span style="color: #333333;">.</span><span style="color: #0000cc;">startComeClose</span><span style="color: #333333;">(</span>asteroitDefencePriorityQueue<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><p>Programı çalıştırdığımızda çıktı şu şekilde olacaktır.</p><p>></p><p>#astreoit 2 distance: 14000<br />simulasyon peek id 1<br /><br />#astreoit 2 distance: 13000<br />simulasyon peek id 1<br /><br />#astreoit 2 distance: 12000<br />simulasyon peek id 1<br /><br />#astreoit 2 distance: 11000<br />simulasyon peek id 1<br /><br />#astreoit 2 distance: 10000<br />simulasyon peek id 1<br /><br />#astreoit 2 distance: 9000<br />simulasyon peek id 2<br /><br />#astreoit 2 distance: 8000<br />simulasyon peek id 2<br /><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiHsLirHKn9G5ZQvJtDQK54ilIRaPJiRgC-GxpnWuesRHDsYV8VzNP3NHriPS0ZqmzgOYEfx6aMcT32FTLq-GToDHa4lQwRc2a_4xnp8BmuTMB72bpIKAJMxPRNzf71wympsf5YCIljmY/s444/asteroid-mars.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Java PriorityQueue Örnek Kod" border="0" data-original-height="444" data-original-width="265" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiHsLirHKn9G5ZQvJtDQK54ilIRaPJiRgC-GxpnWuesRHDsYV8VzNP3NHriPS0ZqmzgOYEfx6aMcT32FTLq-GToDHa4lQwRc2a_4xnp8BmuTMB72bpIKAJMxPRNzf71wympsf5YCIljmY/w239-h400/asteroid-mars.PNG" title="Java PriorityQueue Örnek Kod" width="239" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Java PriorityQueue Örnek Kod</td></tr></tbody></table><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p> <br /></p><p><br /></p><p><br /></p><p><br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-88020814189100340612021-04-16T23:33:00.010-07:002021-12-25T04:04:43.153-08:00JTS CBS Kütüphanesi Rehberi 6 - Douglas Peucker Geometri Basitleştirme ve Yoğunlaştırma<p><a href="https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm" rel="nofollow" target="_blank">Douglas Peucker algoritması </a>(Ramer-Dougles-Peucker de denilmektedir), çizgi parçalarından oluşan bir eğriyi daha az noktalı benzer bir eğriye döndüren algoritmadır. Ürettiğimiz geometrinin çok fazla girintili çıkıntılı olmasını istemediğimiz zaman kullanırız.Vereceğimiz bir tolerans değerinden küçük uzunluktaki çizgi parçalarını birleştirerek orijinal çizgiye benzer ama daha basit bir çizgi elde etmemizi sağlar.</p><p>LocationTech JTS Topology Suite rehberimizin bu bölümünde Douglas Peucker basitleştirme aracını inceleyeceğiz.</p><p> </p><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicWwV_hhzEm_tv7Sg-of8uwJn4jFrQi3iYiJ1HM1EyfMtNJpUnOtEiaqq_x9inGvN8u2xXpvn-tQFneCK1oSKxArSC-Ea8wrbwGMrW2bizWkF5Wc07h9shzUBQ69kxfamfV_HWlSJQiQc/s504/dougles_simplifier.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Douglas Peucker Geometri Basitleştirme" border="0" data-original-height="451" data-original-width="504" height="358" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicWwV_hhzEm_tv7Sg-of8uwJn4jFrQi3iYiJ1HM1EyfMtNJpUnOtEiaqq_x9inGvN8u2xXpvn-tQFneCK1oSKxArSC-Ea8wrbwGMrW2bizWkF5Wc07h9shzUBQ69kxfamfV_HWlSJQiQc/w400-h358/dougles_simplifier.PNG" title="Douglas Peucker Geometri Basitleştirme" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Douglas Peucker Geometri Basitleştirme</td></tr></tbody></table> <p></p><h2 style="text-align: left;">DouglasPeuckerSimplifier</h2><p style="text-align: left;">JTS kütüphanesinde bulunan <b>org.locationtech.jts.simplify.DouglasPeuckerSimplifier </b>sınıfından bir nesne oluşturuken input olarak basitleştireceği <b>Geometry </b>tipinde bir nesne almaktadır. Yani sadece çizgileri değil, poligon ve diğer <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">geometri tiplerini</a> de basitleştirebileceği anlamına geliyor.</p><p style="text-align: left;"><b>setDistanceTolerance(double tolerance) </b>metodu ile de tolerans uzunluk değerini belirliyoruz. <br /></p><p style="text-align: left;"></p><p style="text-align: left;">Önceki bölümlerde de paylaştığım üzere tüm görselleştirme kodlarını <a href="https://github.com/mokszr/jts-egitim" target="_blank">GitHub'da şuradan indirebilirsiniz.</a></p><p style="text-align: left;">Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/GeometriBasitlestirme.java" target="_blank"><b>GeometriBasitlestirme.java</b> </a>sınıfını çalıştırarak siz de görselleştirebilirsiniz.</p><p style="text-align: left;">Örneğimizde, 12 adet noktadan oluşan bir çizgi (LineString) oluşturuyoruz. Daha sonra <b>DouglasPeuckerSimplifier </b>nesnesine parametre olarak veriyoruz. Toleransı da 30 birim olarak belirliyoruz. Basitleştirilmiş LineString nesnesini sonuç olarak üretiyoruz. Görselleştime açısından çizgiler üst üste binmesin diye, basitleştirilmiş versiyonu orijinalinden 100 piksel daha aşağıda çiziyoruz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">20</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">70</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">70</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">90</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">80</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">175</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">200</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">220</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">230</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">130</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">260</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">80</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">310</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">)</span> <span style="color: #333333;">};</span>
LineString lineString <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
DouglasPeuckerSimplifier simplifier <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> DouglasPeuckerSimplifier<span style="color: #333333;">(</span>lineString<span style="color: #333333;">);</span>
simplifier<span style="color: #333333;">.</span><span style="color: #0000cc;">setDistanceTolerance</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">30</span><span style="color: #333333;">);</span>
LineString simplerLineString <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>LineString<span style="color: #333333;">)</span> simplifier<span style="color: #333333;">.</span><span style="color: #0000cc;">getResultGeometry</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"original line coordinate size : "</span> <span style="color: #333333;">+</span> coordinates<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"simplified line coordinate size "</span> <span style="color: #333333;">+</span> simplerLineString<span style="color: #333333;">.</span><span style="color: #0000cc;">getCoordinates</span><span style="color: #333333;">().</span><span style="color: #0000cc;">length</span><span style="color: #333333;">);</span>
</pre></div><h2 style="text-align: left;"> </h2><h2 style="text-align: left;">Geometri Yoğunlaştırma (Densifier)</h2><p style="text-align: left;">Geometri basitleştirmenin tam tersi bir şekilde, elimizdeki çizginin noktaları arasında yeni noktalar üretip geometriyi yoğunlaştırmak isteyebiliriz. Bunun için <b>org.locationtech.jts.densify.Densifier </b>sınıfını kullanacağız. <br /></p><p style="text-align: left;"><b>DouglasPeuckerSimplifier </b>sınıfına benzer şekilde<b> </b>bir geometri parametresi alıyor.<b> </b></p><p style="text-align: left;"><b><b>setDistanceTolerance(double tolerance) </b></b>metodu ile orijinal noktalar arasında hangi sıklıkta yeni noktalar yerleştirmek istediğimizi belirliyoruz.</p><p style="text-align: left;">Basitleştirme örneğindeki LineString'in aynısını burada da kullanacağız. Bu sefer tolerans değerini 15 birim vereceğiz. Yeni üretilen ve orijinal noktaları daha iyi görselleştirmek için, nokta bulunan kısımları küçük daireler ile boyayacağız.</p><p style="text-align: left;">Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/GeometriYogunlastirma.java" target="_blank"><b>GeometriYogunlastirma.java</b> </a>sınıfını çalıştırarak siz de görselleştirebilirsiniz.</p><p style="text-align: left;"></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKq9wbbvkYtRhl-l1KGp1r_1o2bNzOdmLi_BSU3_Ekl3XkfUXtdePR9jSurTWmnGwkGBPOBUWkaqZjg6BO-UfiHJhF7iAk_yxrvgFxTLesyBWqI0KT1eQ5iZVX5C-YTZHesCV-n2i64j8/s449/geometry_densifier.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Geometry Densifier" border="0" data-original-height="449" data-original-width="439" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKq9wbbvkYtRhl-l1KGp1r_1o2bNzOdmLi_BSU3_Ekl3XkfUXtdePR9jSurTWmnGwkGBPOBUWkaqZjg6BO-UfiHJhF7iAk_yxrvgFxTLesyBWqI0KT1eQ5iZVX5C-YTZHesCV-n2i64j8/w391-h400/geometry_densifier.PNG" title="Geometry Densifier" width="391" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Geometry Densifier</td></tr></tbody></table><br /><b></b>
<p></p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">20</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">70</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">70</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">90</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">80</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">175</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">200</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">220</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">230</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">130</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">260</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">80</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">310</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">)</span> <span style="color: #333333;">};</span>
LineString lineString <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
Densifier densifier <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Densifier<span style="color: #333333;">(</span>lineString<span style="color: #333333;">);</span>
densifier<span style="color: #333333;">.</span><span style="color: #0000cc;">setDistanceTolerance</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">15</span><span style="color: #333333;">);</span>
LineString denserLineString <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>LineString<span style="color: #333333;">)</span> densifier<span style="color: #333333;">.</span><span style="color: #0000cc;">getResultGeometry</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"original line coordinate size : "</span> <span style="color: #333333;">+</span> coordinates<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"densified line coordinate size "</span> <span style="color: #333333;">+</span> denserLineString<span style="color: #333333;">.</span><span style="color: #0000cc;">getCoordinates</span><span style="color: #333333;">().</span><span style="color: #0000cc;">length</span><span style="color: #333333;">);</span>
</pre></div><p style="text-align: left;"> </p><p style="text-align: left;"> Önceki bölümler:</p><ol style="text-align: left;"><li> <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">JTS CBS Kütüphanesi Rehberi 1 - Geometri Modeli</a></li><li><a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-2-geometrik.html" target="_blank"> JTS CBS Kütüphanesi Rehberi 2 - Geometrik İlişki Hesaplamaları </a></li><li> <a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-3-geometrik.html" target="_blank">JTS CBS Kütüphanesi Rehberi 3 - Geometrik Alan Hesaplamaları</a></li><li> <a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-4-delaunay-triangulation-voronoi-convex-hull.html " target="_blank">JTS CBS Kütüphanesi Rehberi 4 - Delaunay Üçgenleme, Voronoi Diyagram, Convex Hull </a></li><li> <a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-5-quadtree-nedir-java-ornek.html" target="_blank">JTS CBS Kütüphanesi Rehberi 5 - Quadtree Nedir? Java'da Örnek Kullanım </a></li></ol><p style="text-align: left;"><a href="https://play.google.com/store/books/details?id=4ClVEAAAQBAJ" target="_blank">Download as E-book PDF</a></p><p style="text-align: left;"><br /><b></b></p><p style="text-align: left;"> </p><p style="text-align: left;"> </p><p style="text-align: left;"> </p><p style="text-align: left;"><span style="color: #333333;"></span>
</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-82486153782068969302021-04-09T22:36:00.013-07:002021-04-11T07:03:16.305-07:00Java'da Thread ve Semaphore Kullanımı Bayram Harçlığı Örneği<p>Normal Dede, SemaphoreDede, AtomicDede ve SynchronizedDede torunlarına bayram harçlığını doğru bir şekilde dağıtabilecek mi? Bayram harçlığı örneğiyle Java'da <b>Semaphore</b>, <b>Thread</b>, <b>AtomicInteger </b>ve <b>synchronized </b>yapılarının nasıl kullanıldığını göreceğiz.</p><p> </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik9uV7X_5UkgzuDvDgKbafLxdIXSib-W9fTFe-cwx65R4aWSBbhVSU800uUElWHKJe0542JgXGKyODQF9vgIh2U0Kki5E6jH3R6CW8R51GbHDM8sXM4xCYZjHP-TKyHeI7s_Jbw9rfkG8/s720/osmanlida_bayram_kutlamasi.jpg" style="margin-left: auto; margin-right: auto;"><img alt="Osmanlı'da Bayram Kutlaması" border="0" data-original-height="559" data-original-width="720" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik9uV7X_5UkgzuDvDgKbafLxdIXSib-W9fTFe-cwx65R4aWSBbhVSU800uUElWHKJe0542JgXGKyODQF9vgIh2U0Kki5E6jH3R6CW8R51GbHDM8sXM4xCYZjHP-TKyHeI7s_Jbw9rfkG8/w400-h310/osmanlida_bayram_kutlamasi.jpg" title="Osmanlı'da Bayram Kutlaması" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Osmanlı'da Bayram Kutlaması</td></tr></tbody></table><p></p><h2 style="text-align: left;">Thread Nedir?</h2><p style="text-align: left;">Türkçe'mize iş parçacığı olarak geçmiş bulunan thread'ler bir hesaplama işini yürüten yapılara denir. İşlemcide yürüyen işlemlerde (process) bir veya birden fazla thread çalışabilir. Bu sayede yoğun işlem gücü gerektiren işler farklı threadlere bölünüp, işlemcinin en verimli şekilde kullanılmasını sağlayarak daha az zamanda işin bitmesine yardımcı olurlar. Örneğimizde dedelerinin elini öpüp harçlık alacak olan torunları birer Thread içinde modelleyeceğiz.<br /></p><h2 style="text-align: left;">MultiThread Nedir? </h2><p style="text-align: left;">Basit programlarımızı main thread dediğimiz tek bir threadde çalışacak şekilde yazarız. İşler büyüdükçe yeni threadlere ihtiyaç doğar ve çoklu threadli (multithread) yapılar ortaya çıkar. Burada bilmemiz gereken şey, kullandığımız yazılım dilinin multithread programlamaya ne kadar API desteği verdiğidir. Java multithreading ve concurrency konularında oldukça iyi standart api desteği sunuyor. </p><p style="text-align: left;">İşlemci hızları artık <a href="https://tr.wikipedia.org/wiki/Moore_yasas%C4%B1" rel="nofollow" target="_blank">Moore Yasası</a>'na göre hızlanmıyor. İşlemci üreticileri çareyi daha çok çekirdekli işlemciler üretmekte arıyorlar. Doğal olarak yazılım dünyasının geleceği de bu çok çekirdekleri en verimli kullananların olacak. Paralel programlama gün geçtikçe daha çok önem kazanacağa benziyor. <br /></p><h2 style="text-align: left;">Semaphore Nedir?</h2><p style="text-align: left;">Uçak gemilerinde elinde bayraklarla pilotlara işaretler veren adamı hatırladınız mı? Kalkış Yapabilirsin! Kalkışı İptal Et! Bayrakları kullanış şekline göre farklı mesajlar verebilir. Semaphore da ismini bu bayraklı işaretlerden alıyor. Kodlar işlemcide işletilirken bir thread'e sen devam edebilirsin derken, diğerine "Hooop hemşerim nereye? Sen dur!" demek için kullanılan yapılardır, Semaphore.</p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9SdYr2jIMshyphenhyphenjdLo_zQT9nPltyTu03rPl6D0eu0HcK-Ozi8RVCOTc7efY0NsNCPRpX34pSqElup0arm0sJc5IzFfgVGmefv3UYFsdOd_E0zQleVP5OKc7dYAb6dKA0HG2EGlkfGxoq-Y/s611/java-semaphore-usage.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Java'da Semaphore Kullanımı Örneği" border="0" data-original-height="373" data-original-width="611" height="244" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9SdYr2jIMshyphenhyphenjdLo_zQT9nPltyTu03rPl6D0eu0HcK-Ozi8RVCOTc7efY0NsNCPRpX34pSqElup0arm0sJc5IzFfgVGmefv3UYFsdOd_E0zQleVP5OKc7dYAb6dKA0HG2EGlkfGxoq-Y/w400-h244/java-semaphore-usage.PNG" title="Java'da Semaphore Kullanımı Örneği" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Java'da Semaphore Kullanımı Örneği</td></tr></tbody></table><br /><p style="text-align: left;"></p><h2 style="text-align: left;"><b>Kritik Bölge Sorunu (Critical Section Problem)</b></h2><p style="text-align: left;">Kodumuzda bir data birden fazla thread tarafından paylaşılıyorsa ve değiştirilme ihtimali varsa bu dataya kritik kaynak denir. Birden fazla threadin aynı anda bir kod bloğuna girip oradaki paylaşılan değeri değiştirmeye çalışması sonucu hatalı değerler ve öngörülemeyen sonuçlarla karşılaşabiliriz. Bu probleme kritik bölge problemi deniyor. Örneğimizde dedelerin dağıtmak üzere ellerindeki tuttukları toplam harçlık miktarı kritik kaynağımız olacak. <b></b></p><h2 style="text-align: left;"><b>Mutual Exclusion / Mutually Exclusive / Mutex Nedir?<br /></b></h2><p style="text-align: left;">Tanımladığımız kritik bölgelere aynı anda sedece bir threadin girebilmesi durumuna mutual exclusion denir. Java'da Semaphore tanımlanırken <b>int permits </b>parametresi alır. Bu kaç tane threadin <b>acquire() </b>çağırmasından sonra gelen threadlerin bloklanacağını bildirir. Örneğin 10 değerini verirsek kritik bölgeye girecek ilk 10 threadin devam etmesine izin verirken 11. thread geldiğinde, içerdeki 10 threadden en az birinin release() metodunu çağırmasını bekler ve 11. threadi bloklar. İçerdeki threadlerden biri <b>release()</b> çağırdığında artık blokaj kalkar ve bloklanan thread devam eder. Koronavirüs tedbirlerince AVM'lerde aynı anda bulunabilen müşteri sayısı kısıtına benzetebiliriz. 100 müşteri sınırı var ise, içeri giren hiç bir müşterinin çıkmadığını varsayarsak, ilk 100 müşteriye giriş izni verilir, 101. müşteri girebilmek için içerden bir müşterinin çıkmasını bekler.</p><p style="text-align: left;">Bu bilgiler göz önüne alındığında, kritik bölgeye yalnızca 1 threadin girmesini istediğimiz durumlarda Semaphore permit değerine 1 veririz. Bu özel durumdaki Semaphore nesneleri <b>mutex </b>olarak da adlandırılır.<br /><b></b></p><h2 style="text-align: left;"><b>synchronized Anahtar Kelimesi<br /></b></h2><p style="text-align: left;">Javada kritik kaynakları korumak amacıyla <b>synchronized </b>anahtar kelimesi kullanılır. Önüne geldiği kod bloğuna veya metoda aynı anda sadece bir threadin girmesine izin verir.</p><h2 style="text-align: left;">Bayram Harçlığı Dağıtma Örneği<br /></h2><p style="text-align: left;">Gelelim eğlenceli bölüme. Dedemiz ve 1000 torunu bir ramazan bayramında bayramlaşacaklar. Dedemiz, elindeki çantada toplam 100 Bin TL tutuyor ve her torununa 100 TL bayram harçlığı vermeyi planlıyor. 1000 torun aynı anda dedenin elini öpüp harçık almaya kalkarsa sonuç ne olur? Eğer kritik kaynağını, çantasını, korumaya almadıysa pek hoş şeyler olmaz tahmin edileceği üzere. </p><p style="text-align: left;">Örnek projemizdeki sınıflara yakından bakalım.</p><p style="text-align: left;"><b>Torun.java</b>, dededen alacağı harçlık miktarı bilgisini ve başarılı şekilde alıp almadığı bilgisini tutuyor.</p><p style="text-align: left;"></p><pre style="line-height: 125%; margin: 0px;"><span style="color: #333333;"> </span></pre><div id="preview"><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><table><tbody><tr><td><pre style="line-height: 125%; margin: 0px;"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19</pre></td><td><pre style="line-height: 125%; margin: 0px;"> <span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Torun</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> Integer alinacakHarclik<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">boolean</span> harclikAlabildim<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Torun</span><span style="color: #333333;">(</span>Integer alinacakHarclik<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">alinacakHarclik</span> <span style="color: #333333;">=</span> alinacakHarclik<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">dedeninEliniOp</span><span style="color: #333333;">(</span>IDede dede<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
harclikAlabildim <span style="color: #333333;">=</span> dede<span style="color: #333333;">.</span><span style="color: #0000cc;">harclikVer</span><span style="color: #333333;">(</span>alinacakHarclik<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">boolean</span> <span style="color: #0066bb; font-weight: bold;">isHarclikAlabildim</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> harclikAlabildim<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></td></tr></tbody></table></div>
</div>
<p style="text-align: left;">Farklı yöntemler kullanan dedeler tanımlayacağımız için şu şekilde bir <b>IDede.java</b> interface tanımladık.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><table><tbody><tr><td><pre style="line-height: 125%; margin: 0px;">1
2
3
4
5
6
7
8</pre></td><td><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">interface</span> <span style="color: #bb0066; font-weight: bold;">IDede</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">boolean</span> <span style="color: #0066bb; font-weight: bold;">harclikVer</span><span style="color: #333333;">(</span>Integer alinacakHarclik<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">public</span> Integer <span style="color: #0066bb; font-weight: bold;">getKalanHarclik</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setToplamDagitilacakHarclik</span><span style="color: #333333;">(</span>Integer toplamDagitilacakHarclik<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
</pre></td></tr></tbody></table></div><p style="text-align: left;">Normal Dede'miz çok iyi niyetli. Her gelen toruna sorgu sual sormadan elindekinden veriyor. <b>Dede.java</b> sınıfını şu şekilde tanımladık.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><table><tbody><tr><td><pre style="line-height: 125%; margin: 0px;"> 1
2
3
4
5
6
7
8
9
10
11
12</pre></td><td><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Dede</span> <span style="color: #008800; font-weight: bold;">implements</span> IDede <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> Integer toplamDagitilacakHarclik<span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">boolean</span> <span style="color: #0066bb; font-weight: bold;">harclikVer</span><span style="color: #333333;">(</span>Integer alinacakHarclik<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
toplamDagitilacakHarclik <span style="color: #333333;">=</span> toplamDagitilacakHarclik <span style="color: #333333;">-</span> alinacakHarclik<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">return</span> toplamDagitilacakHarclik <span style="color: #333333;">>=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></td></tr></tbody></table></div><p style="text-align: left;">AtomicDede ise elindeki toplam harçlık miktarını <b>AtomicInteger </b>nesnesi kullanarak tutuyor. AtomicInteger sınıfı, üzerindeki eksiltme arttırma gibi işlemleri atomic olarak halledebiliyor ve araya başka thread girmiyor.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><table><tbody><tr><td><pre style="line-height: 125%; margin: 0px;"> 1
2
3
4
5
6
7
8
9
10
11
12</pre></td><td><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">AtomicDede</span> <span style="color: #008800; font-weight: bold;">implements</span> IDede <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> AtomicInteger toplamDagitilacakHarclik<span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">boolean</span> <span style="color: #0066bb; font-weight: bold;">harclikVer</span><span style="color: #333333;">(</span>Integer alinacakHarclik<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
toplamDagitilacakHarclik<span style="color: #333333;">.</span><span style="color: #0000cc;">addAndGet</span><span style="color: #333333;">(-</span>alinacakHarclik<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">return</span> toplamDagitilacakHarclik<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">()</span> <span style="color: #333333;">>=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></td></tr></tbody></table></div><p style="text-align: left;">SemaphoreDede harçlık verme işini bir kabinde yapıyor ve o kabine aynı anda sadece bir torunu alıyor. Kullandığı Semaphore mutex kilidini kullanarak, harclikVer metoduna ilk giren threadle birlikte <b>acquire() </b>metodu ile Semaphore'daki izin miktarını 1 eksiltiyor. Ve bu ilk giren thread işini bitirene, çıkarken de <b>release() </b>metodunu çağırana kadar da içeriye başka thread almıyor.</p><b></b>
<div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><table><tbody><tr><td><pre style="line-height: 125%; margin: 0px;"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24</pre></td><td><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">SemaphoreDede</span> <span style="color: #008800; font-weight: bold;">implements</span> IDede <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> Integer toplamDagitilacakHarclik<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Semaphore mutex <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Semaphore<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">);</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">boolean</span> <span style="color: #0066bb; font-weight: bold;">harclikVer</span><span style="color: #333333;">(</span>Integer alinacakHarclik<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
mutex<span style="color: #333333;">.</span><span style="color: #0000cc;">acquire</span><span style="color: #333333;">();</span>
toplamDagitilacakHarclik <span style="color: #333333;">=</span> toplamDagitilacakHarclik <span style="color: #333333;">-</span> alinacakHarclik<span style="color: #333333;">;</span>
mutex<span style="color: #333333;">.</span><span style="color: #0000cc;">release</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>InterruptedException e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
e<span style="color: #333333;">.</span><span style="color: #0000cc;">printStackTrace</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> toplamDagitilacakHarclik <span style="color: #333333;">>=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></td></tr></tbody></table></div><p style="text-align: left;">Örnek projemizde <b>ElOpmeHarclikAlmaThread.java</b> ismindeki sınıf ile torunun dedenin elini öpmesini simüle edeceğiz.</p>
<div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><table><tbody><tr><td><pre style="line-height: 125%; margin: 0px;"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18</pre></td><td><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">ElOpmeHarclikAlmaThread</span> <span style="color: #008800; font-weight: bold;">extends</span> Thread <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> IDede dede<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Torun torun<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">ElOpmeHarclikAlmaThread</span><span style="color: #333333;">(</span>IDede dede<span style="color: #333333;">,</span> Torun torun<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">dede</span> <span style="color: #333333;">=</span> dede<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">torun</span> <span style="color: #333333;">=</span> torun<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">run</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
torun<span style="color: #333333;">.</span><span style="color: #0000cc;">dedeninEliniOp</span><span style="color: #333333;">(</span>dede<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></td></tr></tbody></table></div><p style="text-align: left;"></p><p style="text-align: left;"><b>BayramKutlama.java</b> sınıfımızda da simülasyon kodlarımız bulunuyor. Torun sayısı kadar Thread oluşturuyor ve başlatıyoruz.Sonra tüm threadlerin bitmesini <b>join()</b> metodu ile bekliyoruz. En sonunda dedenin elinde kalan para miktarının sıfır olmasını bekliyoruz. Sıfır değil ise işler karışmış demektir.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><table><tbody><tr><td><pre style="line-height: 125%; margin: 0px;"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55</pre></td><td><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">BayramKutlama</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">bayraminizKutluOlsun</span><span style="color: #333333;">(</span>IDede dede<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
List<span style="color: #333333;"><</span>ElOpmeHarclikAlmaThread<span style="color: #333333;">></span> elOpmeThreadleri <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
dede<span style="color: #333333;">.</span><span style="color: #0000cc;">setToplamDagitilacakHarclik</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">100000</span><span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">int</span> torunSayisi <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1000</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> harclikMiktari <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> torunSayisi<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
Torun torun <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Torun<span style="color: #333333;">(</span>harclikMiktari<span style="color: #333333;">);</span>
ElOpmeHarclikAlmaThread elOpmeThread <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ElOpmeHarclikAlmaThread<span style="color: #333333;">(</span>dede<span style="color: #333333;">,</span> torun<span style="color: #333333;">);</span>
elOpmeThreadleri<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>elOpmeThread<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> torunSayisi<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
elOpmeThreadleri<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>i<span style="color: #333333;">).</span><span style="color: #0000cc;">start</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Tum threadlerin bitmesini bekle</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> torunSayisi<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
elOpmeThreadleri<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>i<span style="color: #333333;">).</span><span style="color: #0000cc;">join</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(!</span>elOpmeThreadleri<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>i<span style="color: #333333;">).</span><span style="color: #0000cc;">getTorun</span><span style="color: #333333;">().</span><span style="color: #0000cc;">isHarclikAlabildim</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span> <span style="color: #333333;">(</span>i <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">". Torun harcligini tam alamamis!!"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>InterruptedException e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
e<span style="color: #333333;">.</span><span style="color: #0000cc;">printStackTrace</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span>dede<span style="color: #333333;">.</span><span style="color: #0000cc;">getClass</span><span style="color: #333333;">().</span><span style="color: #0000cc;">getSimpleName</span><span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" Bitirdi. Elinde kalan miktar "</span> <span style="color: #333333;">+</span> dede<span style="color: #333333;">.</span><span style="color: #0000cc;">getKalanHarclik</span><span style="color: #333333;">());</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>dede<span style="color: #333333;">.</span><span style="color: #0000cc;">getKalanHarclik</span><span style="color: #333333;">()</span> <span style="color: #333333;">></span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span>dede<span style="color: #333333;">.</span><span style="color: #0000cc;">getClass</span><span style="color: #333333;">().</span><span style="color: #0000cc;">getSimpleName</span><span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" BASARISIZ!!!"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Dedenin elinde hic para kalmadi. Berhudar olsunlar!"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></td></tr></tbody></table></div><p><b>BayramApp.java</b> sınıfında da tüm dede tiplerimiz için simülasyonumuzu koşturuyoruz. Sonuçları konsola yazdırıyoruz. Üst üste çalıştırarak sonuçların hep aynı olduğunu görüyoruz. Sadece normal Dede sınıfımızda dedemizin elinde kalan miktar sıfırdan farklı oluyor. Diğer dedelerimiz kullandıkları yöntemlerle kritik kaynaklarını korumanın bir yolunu bulmuş görünüyorlar.</p><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihX8G18n1x1yNSNoSfOqhHAQ0PvZpY8gxK3HZbCCb6S-_RFv1LoYs2WdjGJlFBFgYB-kbGdA_HNxpTd2RATcNro_ZiyYsWL0JRiU5XAqKtfM8V7Hyx00i2Cgjb-Ez0L7Vpr3mvpz_G2b4/s495/bayram-harcligi-outpu.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Bayram Harçlığı Output" border="0" data-original-height="354" data-original-width="495" height="286" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihX8G18n1x1yNSNoSfOqhHAQ0PvZpY8gxK3HZbCCb6S-_RFv1LoYs2WdjGJlFBFgYB-kbGdA_HNxpTd2RATcNro_ZiyYsWL0JRiU5XAqKtfM8V7Hyx00i2Cgjb-Ez0L7Vpr3mvpz_G2b4/w400-h286/bayram-harcligi-outpu.PNG" title="Bayram Harçlığı Output" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Bayram Harçlığı Output</td></tr></tbody></table><br /> <p></p><b>Output:</b><br /><p>Dedeler harcliklari dagittiginde ellerinde hic para kalmamasi lazim!<br />--------<br />Basliyoruz<br />--------<br />Dede Bitirdi. Elinde kalan miktar 2700<br />Dede BASARISIZ!!!<br />Dede hesaplama suresi 54<br /><br />AtomicDede Bitirdi. Elinde kalan miktar 0<br />Dedenin elinde hic para kalmadi. Berhudar olsunlar!<br />AtomicDede hesaplama suresi 49<br /><br />SynchronizedDede Bitirdi. Elinde kalan miktar 0<br />Dedenin elinde hic para kalmadi. Berhudar olsunlar!<br />SynchronizedDede hesaplama suresi 51<br /><br />SemaphoreDede Bitirdi. Elinde kalan miktar 0<br />Dedenin elinde hic para kalmadi. Berhudar olsunlar!<br />SemaphoreDede hesaplama suresi 50<br /></p><p>Örnek projemizi <a href="https://github.com/mokszr/bayram-harcligi" target="_blank">GitHub'da şuradan</a> indirip kendiniz de deneyebilirsiniz.</p><p><br /></p><p><br /></p>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-1182699704863936232.post-32046280350642271502021-04-06T22:37:00.014-07:002021-12-25T04:03:47.581-08:00JTS CBS Kütüphanesi Rehberi 5 - Quadtree Nedir? Java'da Örnek Kullanım<p>Her düğümünün (node) 4 adet çocuğu (child) olan ağaç (tree) veri yapısına quadtree denir. Genellikle 2 boyutlu bir yüzeyi 4 eşit alana bölmek için kullanılır. Bu bölümler de yinelemeli olarak 4 er eşit parçaya ayrılır. Bu şekilde her bir alan quadtree yapısında tutulur.</p><p> </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJqe4LxbkdFAUIzfbbY_oreVDQM0TUu26VVabTsQHQuhBPWvbmwDNDDfLKf7agbTJexBNdV5oLolJaDMW0vyDRjaAMpzOPTVDcfaSMNvynt7ago4jsxpLIrVi3HYaU8VZPuQ6Zl-mHloE/s300/quadtree.png" style="margin-left: auto; margin-right: auto;"><img alt="Quadtree nedir?" border="0" data-original-height="300" data-original-width="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJqe4LxbkdFAUIzfbbY_oreVDQM0TUu26VVabTsQHQuhBPWvbmwDNDDfLKf7agbTJexBNdV5oLolJaDMW0vyDRjaAMpzOPTVDcfaSMNvynt7ago4jsxpLIrVi3HYaU8VZPuQ6Zl-mHloE/s16000/quadtree.png" title="Quadtree nedir?" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Quadtree</td></tr></tbody></table><br />Java'da quadtree örneği görselleştirmesini <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">JTS (Java Topology Suite)</a> kütüphanesinde bulunan Quadtree sınıfı ile yapacağız. <p></p><p>Öncelikle 100 adet rastgele nokta türünde geometri tanımlayalım. Bu noktaları tanımladığımız Quadtree nesnesine ekleyeceğiz. </p><p><b>quadTree.insert(Envelope itemEnv, Object item);</b></p><p>insert metodu ile verdiğimiz "item" nesnesi Envlope (zarf, kapsam) ile tanımlanan konuma indekslenir.<b> </b>Daha sonra belli bir arama / tarama dikdörtgeni kullanarak quadtree nesnesinde bu alana denk gelen itemler sorgulanır.</p><p><b>quadTree.query(Envelope searchEnv);</b></p><p><b>query() </b>metodunun Java dokümanında query metodunun döndüğü sonuçlar arasında <b>searchEnv </b>arama alanında olmayan nesnelerin de dönülebileceği belirtilmiş. Yani <b>false positive</b> sonuçlar da dönülebilmektedir. JTS geliştiricileri, sevimsiz bir şekilde, bu false positive sorgu sonuçlarını elemek sorumluluğunu kullanıcıya bırakmışlar. Bu nedenle dönen sorgu sonuçlarını bir kez de tarama poligonuyla kesiştirip, kesişmeyenleri sonuç listesinden sileceğiz. query()'yi kullanmayıp direk poligon ile kesişim hesaplamamamızın sebebi, query metodu ile tree içindeki yüksek sayıdaki nesnelerin çoğunu eleyerek daha az sayıda nesnede kesişim hesaplamamızı sağlaması, bu sayede performans kazancı sağlamasıdır. <br /></p><p>Görselleştirme amacıyla, quadTree'ye eklediğimiz tüm noktaları ekrana çizdireceğiz. Arama tarama dikdörgenimizi ve query sorgusundan dönen noktaları, false positive sonuçları temizlemiş bir şekilde, kırmızı renge boyayacağız. Dışarda kalan noktaları maviye boyayacağız.</p><p><span> </span><b></b>
</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"> GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Random randomX <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Random<span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">());</span>
Random randomY <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Random<span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">);</span>
List<span style="color: #333333;"><</span>Coordinate<span style="color: #333333;">></span> noktaKoordinatlari <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #333399; font-weight: bold;">int</span> noktaSayisi <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">;</span>
Point<span style="color: #333333;">[]</span> noktalar <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Point<span style="color: #333333;">[</span>noktaSayisi<span style="color: #333333;">];</span>
Quadtree quadTree <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Quadtree<span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><=</span> noktaSayisi<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> xRandomlySelected <span style="color: #333333;">=</span> randomX<span style="color: #333333;">.</span><span style="color: #0000cc;">nextInt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">65</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> yRandomlySelected <span style="color: #333333;">=</span> randomY<span style="color: #333333;">.</span><span style="color: #0000cc;">nextInt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">;</span>
Coordinate coordinate <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span>xRandomlySelected<span style="color: #333333;">,</span> yRandomlySelected<span style="color: #333333;">);</span>
noktaKoordinatlari<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>coordinate<span style="color: #333333;">);</span>
noktalar<span style="color: #333333;">[</span>i<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPoint</span><span style="color: #333333;">(</span>coordinate<span style="color: #333333;">);</span>
quadTree<span style="color: #333333;">.</span><span style="color: #0000cc;">insert</span><span style="color: #333333;">(</span>noktalar<span style="color: #333333;">[</span>i<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">].</span><span style="color: #0000cc;">getEnvelopeInternal</span><span style="color: #333333;">(),</span> noktalar<span style="color: #333333;">[</span>i<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">]);</span>
<span style="color: #333333;">}</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Polygon cercevePoligon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
List<span style="color: #333333;"><</span>Object<span style="color: #333333;">></span> cerceveOlasiKapsananNoktalar <span style="color: #333333;">=</span> quadTree<span style="color: #333333;">.</span><span style="color: #0000cc;">query</span><span style="color: #333333;">(</span>cercevePoligon<span style="color: #333333;">.</span><span style="color: #0000cc;">getEnvelopeInternal</span><span style="color: #333333;">());</span>
List<span style="color: #333333;"><</span>Point<span style="color: #333333;">></span> falsePositives <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span>Object c <span style="color: #333333;">:</span> cerceveOlasiKapsananNoktalar<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
Point p <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Point<span style="color: #333333;">)</span> c<span style="color: #333333;">;</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span>p <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" intersects polygon: "</span> <span style="color: #333333;">+</span> cercevePoligon<span style="color: #333333;">.</span><span style="color: #0000cc;">intersects</span><span style="color: #333333;">(</span>p<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" envlope "</span> <span style="color: #333333;">+</span> p<span style="color: #333333;">.</span><span style="color: #0000cc;">getEnvelopeInternal</span><span style="color: #333333;">());</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(!</span>cercevePoligon<span style="color: #333333;">.</span><span style="color: #0000cc;">intersects</span><span style="color: #333333;">(</span>p<span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
falsePositives<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>p<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
cerceveOlasiKapsananNoktalar<span style="color: #333333;">.</span><span style="color: #0000cc;">removeAll</span><span style="color: #333333;">(</span>falsePositives<span style="color: #333333;">);</span>
</pre></div><p><br /><br /><b></b></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8ZAttVoHYDe0jHemvNPamky41VFfGI9pCw6IriazbiymKhemHEnoprFnNYfktc4Qega-IWNLlb5d-zybGOCEE1ntCv0aD0EbeLTqTXs4uVVftBcdmu6QehoqgD7ith9d-CskHM6YlBRM/s452/jts_quadtree_visualisation.PNG" style="margin-left: auto; margin-right: auto;"><img alt="JTS Quadtree Visualisation" border="0" data-original-height="452" data-original-width="444" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8ZAttVoHYDe0jHemvNPamky41VFfGI9pCw6IriazbiymKhemHEnoprFnNYfktc4Qega-IWNLlb5d-zybGOCEE1ntCv0aD0EbeLTqTXs4uVVftBcdmu6QehoqgD7ith9d-CskHM6YlBRM/w393-h400/jts_quadtree_visualisation.PNG" title="JTS Quadtree Visualisation" width="393" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">JTS Quadtree Visualisation</td></tr></tbody></table><br /><p><a href="https://github.com/mokszr/jts-egitim" target="_blank">Github'daki örnek JTS eğitim</a> projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/QuadtreeGorsellestirme.java" rel="nofollow" target="_blank">QuadtreeGorsellestirme.java </a>sınıfını çalıştırarak görselleştirebilirsiniz.</p><p><b> </b></p><p style="text-align: left;"> Önceki bölümler:</p><ol style="text-align: left;"><li> <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">JTS CBS Kütüphanesi Rehberi 1 - Geometri Modeli</a></li><li><a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-2-geometrik.html" target="_blank"> JTS CBS Kütüphanesi Rehberi 2 - Geometrik İlişki Hesaplamaları </a></li><li> <a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-3-geometrik.html" target="_blank">JTS CBS Kütüphanesi Rehberi 3 - Geometrik Alan Hesaplamaları</a></li><li> <a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-4-delaunay-triangulation-voronoi-convex-hull.html " target="_blank">JTS CBS Kütüphanesi Rehberi 4 - Delaunay Üçgenleme, Voronoi Diyagram, Convex Hull </a></li></ol><p>Sonraki Bölümler:</p><p><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-6-douglas-peucker-simplifier.html" target="_blank">JTS CBS Kütüphanesi Rehberi 6 - Douglas Peucker Geometri Basitleştirme ve Yoğunlaştırma </a><br /></p><p><b> </b><br /></p><p><b> </b><a href="https://play.google.com/store/books/details?id=4ClVEAAAQBAJ" target="_blank">Download as E-book PDF</a></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-2139868927010423672021-04-02T22:27:00.009-07:002021-12-25T04:05:07.796-08:00JTS CBS Kütüphanesi Rehberi 4 - Delaunay Üçgenleme, Voronoi Diyagram, Convex Hull<p style="text-align: left;"> Previously on JTS</p><ol style="text-align: left;"><li> <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">JTS CBS Kütüphanesi Rehberi 1 - Geometri Modeli</a></li><li><a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-2-geometrik.html" target="_blank"> JTS CBS Kütüphanesi Rehberi 2 - Geometrik İlişki Hesaplamaları </a></li><li> <a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-3-geometrik.html" target="_blank">JTS CBS Kütüphanesi Rehberi 3 - Geometrik Alan Hesaplamaları</a></li></ol><p>Merhabalar. JTS (Java Topology Suite) rehberimizin önceki bölümlerinde <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">geometri modellerini tanımış</a>, <a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-2-geometrik.html" target="_blank">geometrilerin birbiri ile ilişkilerini incelemiş</a>, daha sonra ise <a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-3-geometrik.html" target="_blank">geometrik alan hesaplamaları üzerinde durmuştuk</a>. Bu bölümde ise Delaunay Triangulation üçgenleme algoritması ile nasıl üçgenler oluşturulacağını, Voronoi diyagramı üretmeyi ve convex hull poligonu üretimini göreceğiz. Tüm görselleştirme örnek kodlarına <a href="https://github.com/mokszr/jts-egitim" target="_blank">GitHub'da şuradan</a> ulaşabileceğinizi hatırlatarak başlayalım. <br /></p><h3 style="text-align: left;">Delaunay Triangulation / Üçgenleme</h3><p style="text-align: left;"><a href="https://en.wikipedia.org/wiki/Delaunay_triangulation" rel="nofollow" target="_blank">Delaunay triangulation / üçgenleme algoritması</a>, bir nokta setinden anlamlı üçgenler oluşturma yöntemidir. Yüzey modelleme, (terrain modelling), mesh üretme ve rota planlama gibi alanlarda kullanılabilmektedir. Biz örneğimizde rastgele koordinatlardan oluşan bir nokta seti oluşturup JTS'den <b>DelaunayTriangulationBuilder </b>sınıfını kullanarak bu noktalardan bize üçgenler üretmesini isteyeceğiz. Nokta sayısını 100 ve 1000 yaparak iki defa çalıştırıp çıkan sonuçları görselleştireceğiz. Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/DelaunayUcgenleme.java" target="_blank">DelaunayUcgenleme.java </a>sınıfını çalıştırarak görselleştirebilirsiniz. <br /></p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Random randomX <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Random<span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">());</span>
Random randomY <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Random<span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">);</span>
List<span style="color: #333333;"><</span>Coordinate<span style="color: #333333;">></span> coords <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #333399; font-weight: bold;">int</span> noktaSayisi <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><=</span> noktaSayisi<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> xRandomlySelected <span style="color: #333333;">=</span> randomX<span style="color: #333333;">.</span><span style="color: #0000cc;">nextInt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">405</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">25</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> yRandomlySelected <span style="color: #333333;">=</span> randomY<span style="color: #333333;">.</span><span style="color: #0000cc;">nextInt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">405</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">20</span><span style="color: #333333;">;</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span>i <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">". Rastgele secilen nokta "</span> <span style="color: #333333;">+</span> xRandomlySelected <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">", "</span> <span style="color: #333333;">+</span> yRandomlySelected<span style="color: #333333;">);</span>
coords<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span>xRandomlySelected<span style="color: #333333;">,</span> yRandomlySelected<span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
DelaunayTriangulationBuilder ucgenBuilder <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> DelaunayTriangulationBuilder<span style="color: #333333;">();</span>
ucgenBuilder<span style="color: #333333;">.</span><span style="color: #0000cc;">setSites</span><span style="color: #333333;">(</span>coords<span style="color: #333333;">);</span>
Geometry triangles <span style="color: #333333;">=</span> ucgenBuilder<span style="color: #333333;">.</span><span style="color: #0000cc;">getTriangles</span><span style="color: #333333;">(</span>geometryFactory<span style="color: #333333;">);</span>
List<span style="color: #333333;"><</span>Polygon<span style="color: #333333;">></span> uretilenUcgenler <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>triangles <span style="color: #008800; font-weight: bold;">instanceof</span> GeometryCollection<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
GeometryCollection geometryCollection <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>GeometryCollection<span style="color: #333333;">)</span> triangles<span style="color: #333333;">;</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Üretilen üçgen sayısı: "</span> <span style="color: #333333;">+</span> geometryCollection<span style="color: #333333;">.</span><span style="color: #0000cc;">getNumGeometries</span><span style="color: #333333;">());</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> geometryCollection<span style="color: #333333;">.</span><span style="color: #0000cc;">getNumGeometries</span><span style="color: #333333;">();</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
Polygon ucgen <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Polygon<span style="color: #333333;">)</span> geometryCollection<span style="color: #333333;">.</span><span style="color: #0000cc;">getGeometryN</span><span style="color: #333333;">(</span>i<span style="color: #333333;">);</span>
uretilenUcgenler<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>ucgen<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><p style="text-align: left;"><br /></p><div class="separator" style="clear: both; text-align: center;"></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsziYZruDY6Rx9Qc54o9YW6apzpUsW33WcVVJNC_wtByoZm6qqbiCzyy3gI3zufS9rphJtFQmN-XB1p8EecWk9LFW6SD59wqtRatg_mWz3wdD4hQXKYv01trnAB9LxYzrqz0eQCuPLtNc/s445/delaunay_triangulation_ucgenleme_.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Delaunay triangulation / üçgenleme" border="0" data-original-height="445" data-original-width="439" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsziYZruDY6Rx9Qc54o9YW6apzpUsW33WcVVJNC_wtByoZm6qqbiCzyy3gI3zufS9rphJtFQmN-XB1p8EecWk9LFW6SD59wqtRatg_mWz3wdD4hQXKYv01trnAB9LxYzrqz0eQCuPLtNc/w395-h400/delaunay_triangulation_ucgenleme_.PNG" title="Delaunay triangulation / üçgenleme" width="395" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Delaunay triangulation / üçgenleme</td></tr></tbody></table><p></p><p>Nokta sayısını 1000 yaparsak aşağıdaki gibi bir çizimle karşılaşıyoruz. <br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-wgWlNXGc4gzkdfaD9ehzWkN4NZhqLdL1Uw1UEpNP3a3YHu80hu442UAI503n3rwRrvxjyxjamCTwruJ4AWJVciiHNIPzNO678HvPZk8qkfcQXSRr_gJ6hMupTD4jMltGZI2oi0XcrYo/s469/delaunay_triangulation_ucgenleme_1000_nokta.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Delaunay triangulation / üçgenleme noktalar" border="0" data-original-height="454" data-original-width="469" height="388" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-wgWlNXGc4gzkdfaD9ehzWkN4NZhqLdL1Uw1UEpNP3a3YHu80hu442UAI503n3rwRrvxjyxjamCTwruJ4AWJVciiHNIPzNO678HvPZk8qkfcQXSRr_gJ6hMupTD4jMltGZI2oi0XcrYo/w400-h388/delaunay_triangulation_ucgenleme_1000_nokta.PNG" title="Delaunay triangulation / üçgenleme noktalar" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Delaunay triangulation / üçgenleme noktalar</td></tr></tbody></table><p></p><h3 style="text-align: left;">Voronoi Diagram / Diyagram<br /></h3><p style="text-align: left;">Matematikte, bir <a href="https://en.wikipedia.org/wiki/Voronoi_diagram" rel="nofollow" target="_blank">Voronoi diyagramı</a>, bir düzlemin belirli bir nesne kümesinin her birine yakın bölgelere bölünmesidir. En basitinden, bu nesneler düzlemdeki sonlu sayıda noktadır (tohumlar, siteler veya oluşturucular olarak adlandırılır). Her tohum için, o tohuma diğerlerinden daha yakın olan düzlemin tüm noktalarından oluşan, Voronoi hücresi (Voronoi cell) adı verilen bir bölge vardır. Biyolojiden kimyaya, sağlıktan mühendisliğe çok çeşitli kullanım alanları mevut.</p><p style="text-align: left;">Üçgenleme örneğimize benzer şekilde rastgele 100 noktadan <b>VoronoiDiagramBuilder </b>sınıfını kullanarak <b>Voronoi diyagramı</b> oluşturacağız. Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/VoronoiDiagramGorsellestirme.java" target="_blank">VoronoiDiagramGorsellestirme.java </a>sınıfını çalıştırarak görselleştirebilirsiniz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Random randomX <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Random<span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">());</span>
Random randomY <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Random<span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">);</span>
List<span style="color: #333333;"><</span>Coordinate<span style="color: #333333;">></span> coords <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #333399; font-weight: bold;">int</span> noktaSayisi <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><=</span> noktaSayisi<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> xRandomlySelected <span style="color: #333333;">=</span> randomX<span style="color: #333333;">.</span><span style="color: #0000cc;">nextInt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">65</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> yRandomlySelected <span style="color: #333333;">=</span> randomY<span style="color: #333333;">.</span><span style="color: #0000cc;">nextInt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">;</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span>i <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">". Rastgele secilen nokta "</span> <span style="color: #333333;">+</span> xRandomlySelected <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">", "</span> <span style="color: #333333;">+</span> yRandomlySelected<span style="color: #333333;">);</span>
coords<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span>xRandomlySelected<span style="color: #333333;">,</span> yRandomlySelected<span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
VoronoiDiagramBuilder diagramBuilder <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> VoronoiDiagramBuilder<span style="color: #333333;">();</span>
diagramBuilder<span style="color: #333333;">.</span><span style="color: #0000cc;">setSites</span><span style="color: #333333;">(</span>coords<span style="color: #333333;">);</span>
Geometry triangles <span style="color: #333333;">=</span> diagramBuilder<span style="color: #333333;">.</span><span style="color: #0000cc;">getDiagram</span><span style="color: #333333;">(</span>geometryFactory<span style="color: #333333;">);</span>
List<span style="color: #333333;"><</span>Polygon<span style="color: #333333;">></span> uretilenPoligonlar <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>triangles <span style="color: #008800; font-weight: bold;">instanceof</span> GeometryCollection<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
GeometryCollection geometryCollection <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>GeometryCollection<span style="color: #333333;">)</span> triangles<span style="color: #333333;">;</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Üretilen poligon sayısı: "</span> <span style="color: #333333;">+</span> geometryCollection<span style="color: #333333;">.</span><span style="color: #0000cc;">getNumGeometries</span><span style="color: #333333;">());</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> geometryCollection<span style="color: #333333;">.</span><span style="color: #0000cc;">getNumGeometries</span><span style="color: #333333;">();</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
Polygon poligon <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Polygon<span style="color: #333333;">)</span> geometryCollection<span style="color: #333333;">.</span><span style="color: #0000cc;">getGeometryN</span><span style="color: #333333;">(</span>i<span style="color: #333333;">);</span>
uretilenPoligonlar<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>poligon<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><p style="text-align: left;"> </p><p style="text-align: left;"></p><p></p><p style="text-align: left;"></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCo3hACJOKA0IbM1wmmekxCsNzrlJ4Bpz_MSREB2SpR5sgbMLZHx7lNgLJI7xodY4V22dIxtGd58yLzZWTfkTo0PtDN0FJzQZmHbCcRH4uzsqoMlMJ5fLJKcYF7yMQnxnLptr9ZchzKAo/s447/voronoi_diagram.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Voronoi Diagram / Diyagram" border="0" data-original-height="447" data-original-width="441" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCo3hACJOKA0IbM1wmmekxCsNzrlJ4Bpz_MSREB2SpR5sgbMLZHx7lNgLJI7xodY4V22dIxtGd58yLzZWTfkTo0PtDN0FJzQZmHbCcRH4uzsqoMlMJ5fLJKcYF7yMQnxnLptr9ZchzKAo/w395-h400/voronoi_diagram.PNG" title="Voronoi Diagram / Diyagram" width="395" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Voronoi Diagram / Diyagram</td></tr></tbody></table><br /><p></p><h3 style="text-align: left;">Convex Hull - Dışbükey Örtü, Zarf</h3><p style="text-align: left;"></p><p><a href="https://en.wikipedia.org/wiki/Convex_hull" rel="nofollow" target="_blank">Convex hull</a>, bir geometrinin tüm noktalarını kapsayan en küçük poligon olarak tanımlanabilir. Örneğimizde, rastgele tanımladığımız 100 noktadan bir MultiPoint nesnesi oluşturacak ve bu nesnenin <b>convexHull()</b> metodu ile zarf poligonunu üreteceğiz. Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/ConvexHullGorsellestirme.java" target="_blank">ConvexHullGorsellestirme.java </a>sınıfını çalıştırarak görselleştirebilirsiniz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Random randomX <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Random<span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">());</span>
Random randomY <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Random<span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">);</span>
List<span style="color: #333333;"><</span>Coordinate<span style="color: #333333;">></span> noktaKoordinatlari <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #333399; font-weight: bold;">int</span> noktaSayisi <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">;</span>
Point<span style="color: #333333;">[]</span> noktalar <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Point<span style="color: #333333;">[</span>noktaSayisi<span style="color: #333333;">];</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><=</span> noktaSayisi<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> xRandomlySelected <span style="color: #333333;">=</span> randomX<span style="color: #333333;">.</span><span style="color: #0000cc;">nextInt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">65</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> yRandomlySelected <span style="color: #333333;">=</span> randomY<span style="color: #333333;">.</span><span style="color: #0000cc;">nextInt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">;</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span>i <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">". Rastgele secilen nokta "</span> <span style="color: #333333;">+</span> xRandomlySelected <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">", "</span> <span style="color: #333333;">+</span> yRandomlySelected<span style="color: #333333;">);</span>
Coordinate coordinate <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span>xRandomlySelected<span style="color: #333333;">,</span> yRandomlySelected<span style="color: #333333;">);</span>
noktaKoordinatlari<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>coordinate<span style="color: #333333;">);</span>
noktalar<span style="color: #333333;">[</span>i<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPoint</span><span style="color: #333333;">(</span>coordinate<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
MultiPoint multiPoint <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createMultiPoint</span><span style="color: #333333;">(</span>noktalar<span style="color: #333333;">);</span>
Polygon convexHull <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Polygon<span style="color: #333333;">)</span> multiPoint<span style="color: #333333;">.</span><span style="color: #0000cc;">convexHull</span><span style="color: #333333;">();</span>
</pre></div><p><br /></p><div class="separator" style="clear: both; text-align: center;"></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4mABkoeyZBWyEJTEHCXpPJ-hiSZIX-RKP3P6AA5IWLCF-BtnNGzPncb28J-iX1Ot2673aiFoVczxi1eDe9z2HEClfoU78ZErt6NSPOFWY-2pg4TIDh-t2AIPSs8Wms5x0WeStzujcN18/s446/convex_hull.PNG" style="margin-left: auto; margin-right: auto;"><img alt="Convex Hull - Zarf" border="0" data-original-height="446" data-original-width="439" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4mABkoeyZBWyEJTEHCXpPJ-hiSZIX-RKP3P6AA5IWLCF-BtnNGzPncb28J-iX1Ot2673aiFoVczxi1eDe9z2HEClfoU78ZErt6NSPOFWY-2pg4TIDh-t2AIPSs8Wms5x0WeStzujcN18/w394-h400/convex_hull.PNG" title="Convex Hull - Zarf" width="394" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Convex Hull - Zarf</td></tr></tbody></table><p></p><p style="text-align: left;">Bu bölümde Delaunay üçgenlemesi ile bir nokta setinden nasıl üçgen üretileceğini, nasıl Voronoi diyagram oluşturulacağını, convex hull poligon geometrisinin nasıl hesaplanacağını gördük. Faydalı olması dileğiyle... <br /></p><p style="text-align: left;">Önceki Bölümler<br /></p><ol style="text-align: left;"><li> <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">JTS CBS Kütüphanesi Rehberi 1 - Geometri Modeli</a></li><li><a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-2-geometrik.html" target="_blank"> JTS CBS Kütüphanesi Rehberi 2 - Geometrik İlişki Hesaplamaları </a></li><li> <a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-3-geometrik.html" target="_blank">JTS CBS Kütüphanesi Rehberi 3 - Geometrik Alan Hesaplamaları</a></li></ol><p>Sonraki Bölümler:</p><p><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-5-quadtree-nedir-java-ornek.html" target="_blank">JTS CBS Kütüphanesi Rehberi 5 - Quadtree Nedir? Java'da Örnek Kullanım</a></p><p><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-6-douglas-peucker-simplifier.html" target="_blank">JTS CBS Kütüphanesi Rehberi 6 - Douglas Peucker Geometri Basitleştirme ve Yoğunlaştırma </a> </p><p> </p><p><a href="https://play.google.com/store/books/details?id=4ClVEAAAQBAJ" target="_blank">Download as E-book PDF</a> <br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-86471176734563703472021-03-21T02:07:00.015-07:002021-12-25T04:05:25.660-08:00JTS CBS Kütüphanesi Rehberi 3 - Geometrik Alan Hesaplamaları<div class="separator"><h3 style="margin-left: 1em; margin-right: 1em; text-align: left;"></h3></div><p style="text-align: left;">Previously on JTS</p><ol style="text-align: left;"><li> <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">JTS CBS Kütüphanesi Rehberi 1 - Geometri Modeli</a></li><li><a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-2-geometrik.html" target="_blank">JTS CBS Kütüphanesi Rehberi 2 - Geometrik İlişki Hesaplamaları </a></li></ol><p style="text-align: left;">Merhabalar. JTS (Java Topology Suite) rehberimizin önceki bölümlerinde <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">geometri modellerini tanımış</a>, daha sonra ise <a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-2-geometrik.html" target="_blank">geometrilerin birbiri ile ilişkilerini incelemiştik</a>. Bu bölümde alan hesaplama yetenekleri üzerinde duracağız. Tüm görselleştirme örnek kodlarına <a href="https://github.com/mokszr/jts-egitim" target="_blank">GitHub'da şuradan</a> ulaşabileceğinizi hatırlatarak başlayalım. <br /></p><h3 style="text-align: left;">Intersection - Kesişim Alanı Hesaplama </h3><p>İki adet poligon tanımlayıp bunların kesişim alanını <b>intersection() </b>metodu ile hesaplatıp farklı renkle boyayalım. Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/KesisimAlanHesaplama.java" target="_blank">KesisimAlanHesaplama.java </a>sınıfını çalıştırarak görselleştirebilirsiniz. </p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">325</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">90</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates2 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">400</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">)};</span>
Polygon maviPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
Polygon sariPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates2<span style="color: #333333;">);</span>
Polygon kesisimAlani <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Polygon<span style="color: #333333;">)</span> sariPolygon<span style="color: #333333;">.</span><span style="color: #0000cc;">intersection</span><span style="color: #333333;">(</span>maviPolygon<span style="color: #333333;">);</span>
</pre></div><p> </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghfFeOGtc2B6XChp8-QdioS5Tp91kxbVZNNjy6CeZy-Rk2SZKl2FiGdtvm8bXRHBVm9IJBzzs-k3V6HHwD_BKoC1YthIzA6RaTSQMtaZuX2TLV2pvBhqmoS1LHLIeD2M67Ta0vMxALK-A/s451/kesisim_alan_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Geometrik Kesişim Alan Hesaplama" border="0" data-original-height="451" data-original-width="444" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghfFeOGtc2B6XChp8-QdioS5Tp91kxbVZNNjy6CeZy-Rk2SZKl2FiGdtvm8bXRHBVm9IJBzzs-k3V6HHwD_BKoC1YthIzA6RaTSQMtaZuX2TLV2pvBhqmoS1LHLIeD2M67Ta0vMxALK-A/w394-h400/kesisim_alan_hesaplama.png" title="Geometrik Kesişim Alan Hesaplama" width="394" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Geometrik Kesişim Alan Hesaplama</td></tr></tbody></table><br /><h3 style="text-align: left;">Union - Birleşim Alanı Hesaplama<br /></h3><p style="text-align: left;">Kesişim örneğinde tanımladığımız mavi ve sarı poligonun birleşim alanını <b>union()</b> metodu ile hesaplatıp boyayalım. Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/BirlesimAlanHesaplama.java" target="_blank">BirlesimAlanHesaplama.java</a> sınıfını çalıştırarak görselleştirebilirsiniz. </p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">325</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">90</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates2 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">400</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">)};</span>
Polygon maviPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
Polygon sariPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates2<span style="color: #333333;">);</span>
Polygon birlesimPoligonu <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Polygon<span style="color: #333333;">)</span> sariPolygon<span style="color: #333333;">.</span><span style="color: #0000cc;">union</span><span style="color: #333333;">(</span>maviPolygon<span style="color: #333333;">);</span>
</pre></div><p style="text-align: left;"> </p><p style="text-align: left;"></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLin_cwnzVi1EH-lDWupZxC19evhVXpaQO8jTgJ_JOsR-5B8_4qtThpGsygiZL3wZcXwgy3D2q7cytH6k0JEhoQ5D72CRNQjBEhAMgPOM-qMhl5l9PPqji_-dvVOUie6bVWn-zwt9kwSg/s447/birlesim_alan_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Birleşim Alan Hesaplama (Union)" border="0" data-original-height="447" data-original-width="440" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLin_cwnzVi1EH-lDWupZxC19evhVXpaQO8jTgJ_JOsR-5B8_4qtThpGsygiZL3wZcXwgy3D2q7cytH6k0JEhoQ5D72CRNQjBEhAMgPOM-qMhl5l9PPqji_-dvVOUie6bVWn-zwt9kwSg/w394-h400/birlesim_alan_hesaplama.png" title="Birleşim Alan Hesaplama (Union)" width="394" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Birleşim Alan Hesaplama (Union)</td></tr></tbody></table><br /><p></p><p style="text-align: left;"></p><p style="text-align: left;"></p><p style="text-align: left;"></p><p style="text-align: left;"></p><h3 style="text-align: left;">Unary Union - Tekil Birleşim Alanı Hesaplama<br /></h3><p style="text-align: left;">Geometri parametresi almayan <b>union()</b> metodu tekil birleşim operasyonunu gerçekleştirmektedir. Çağrıldığı geometri nesnesi içindeki geometrileri birleştirip bir sonuç dönmektedir. Bizim örneğimizde sarı ve mavi poligondan bir adet <b>MultiPolygon </b>nesnesi oluşturup bu nesnede unary <b>union()</b> metodunu kullanarak yine aynı birleşim poligonunu elde ettiğimizi göreceğiz. Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/TekilBirlesimAlanHesaplama.java" target="_blank">TekilBirlesimAlanHesaplama.java </a>sınıfını çalıştırarak görselleştirebilirsiniz. <br /></p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">325</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">90</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates2 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">400</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">)};</span>
Polygon maviPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
Polygon sariPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates2<span style="color: #333333;">);</span>
MultiPolygon multiPoligon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createMultiPolygon</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Polygon<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span>sariPolygon<span style="color: #333333;">,</span> maviPolygon<span style="color: #333333;">});</span>
Polygon birlesimPoligonu <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Polygon<span style="color: #333333;">)</span> multiPoligon<span style="color: #333333;">.</span><span style="color: #0000cc;">union</span><span style="color: #333333;">();</span>
</pre></div><p style="text-align: left;"> </p><p style="text-align: left;"></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYUgc-lhmjBISFVuUSnwz_Zg_fef5wBgYkTtXNR0l4MGF3ayj98PnepI0tVbIqXpN3np1ho95XUvVIgiCmDnRoefoFRAac67vOETNHjEOaFMYJwE7MPd-B4v4h4Xn3Q8T0wulMGP0wb1U/s449/tekil_birlesim_alan_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Tekil Birleşim Alan Hesaplama (Unary Union)" border="0" data-original-height="449" data-original-width="442" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYUgc-lhmjBISFVuUSnwz_Zg_fef5wBgYkTtXNR0l4MGF3ayj98PnepI0tVbIqXpN3np1ho95XUvVIgiCmDnRoefoFRAac67vOETNHjEOaFMYJwE7MPd-B4v4h4Xn3Q8T0wulMGP0wb1U/w394-h400/tekil_birlesim_alan_hesaplama.png" title="Tekil Birleşim Alan Hesaplama (Unary Union)" width="394" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Tekil Birleşim Alan Hesaplama (Unary Union)</td></tr></tbody></table><br /><p></p><p style="text-align: left;"></p><h3 style="text-align: left;">Difference - Fark Alanı Hesaplama<br /></h3><p style="text-align: left;">Yine aynı mavi ve sarı poligon ile devam ediyoruz. Sarı poligonun mavi poligondan farkını <b>difference()</b> metodu ile hesaplatıp boyayalım. Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/FarkAlanHesaplama.java" target="_blank">FarkAlanHesaplama.java </a>sınıfını çalıştırarak görselleştirebilirsiniz. <br /></p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">325</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">90</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates2 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">400</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">)};</span>
Polygon maviPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
Polygon sariPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates2<span style="color: #333333;">);</span>
Polygon farkPoligonu <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Polygon<span style="color: #333333;">)</span> sariPolygon<span style="color: #333333;">.</span><span style="color: #0000cc;">difference</span><span style="color: #333333;">(</span>maviPolygon<span style="color: #333333;">);</span>
</pre></div><p style="text-align: left;"> </p><p style="text-align: left;"></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio5ZOovwftyy_PZld6FeaXsjJdshamj28DpOfjAI-Z8LozZRdhy7OeDPCZK8VhL2EN-YI1LoZuchHCveDTbDtBgqUFL9fwvZfIx9oELfS-WaUWthEzicaBB1gNuuax1weK0FtX6OZ9jdc/s447/fark_alan_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Fark Alan Hesaplama (Difference)" border="0" data-original-height="447" data-original-width="443" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio5ZOovwftyy_PZld6FeaXsjJdshamj28DpOfjAI-Z8LozZRdhy7OeDPCZK8VhL2EN-YI1LoZuchHCveDTbDtBgqUFL9fwvZfIx9oELfS-WaUWthEzicaBB1gNuuax1weK0FtX6OZ9jdc/w396-h400/fark_alan_hesaplama.png" title="Fark Alan Hesaplama (Difference)" width="396" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Fark Alan Hesaplama (Difference)</td></tr></tbody></table><br /><p></p><p style="text-align: left;"></p><h3 style="text-align: left;">Symetric Difference - Simetrik Fark Alanı Hesaplama<br /></h3><p style="text-align: left;">Bu örnekten yola çıkarak <b>symDifference()</b> metodunu kullanarak hesapladığımız simetrik farkı, sarı poligonun mavi poligondan farkı ile, mavinin sarıdan farkının birleşimi olarak tanımlayabiliriz. Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/SimetrikFarkAlanHesaplama.java" target="_blank">SimetrikFarkAlanHesaplama.java </a>sınıfını çalıştırarak görselleştirebilirsiniz. </p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">325</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">90</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates2 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">400</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">)};</span>
Polygon maviPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
Polygon sariPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates2<span style="color: #333333;">);</span>
MultiPolygon simetrikFarkPoligonu <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>MultiPolygon<span style="color: #333333;">)</span> sariPolygon<span style="color: #333333;">.</span><span style="color: #0000cc;">symDifference</span><span style="color: #333333;">(</span>maviPolygon<span style="color: #333333;">);</span>
</pre></div><p style="text-align: left;"> </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh55pV-RvYFvYyMkKTAPVvyzAZ422Z_-d9A7GmcYqY13MSXRWdiaW83eh_53_h23CEJc2ktmqnoLmh92ktGqTRasAwgUggrd-XFXJR4ipOVrToLwcTFDoNufqYKKHwx6U-Fz7ME4DQEwbU/s450/simetrik_fark_alan_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Simetrik Fark Alan Hesaplama (Symetric Difference)" border="0" data-original-height="450" data-original-width="439" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh55pV-RvYFvYyMkKTAPVvyzAZ422Z_-d9A7GmcYqY13MSXRWdiaW83eh_53_h23CEJc2ktmqnoLmh92ktGqTRasAwgUggrd-XFXJR4ipOVrToLwcTFDoNufqYKKHwx6U-Fz7ME4DQEwbU/w390-h400/simetrik_fark_alan_hesaplama.png" title="Simetrik Fark Alan Hesaplama (Symetric Difference)" width="390" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Simetrik Fark Alan Hesaplama (Symetric Difference)</td></tr></tbody></table><br /><p style="text-align: left;"></p><p style="text-align: left;"></p><p style="text-align: left;"></p><p style="text-align: left;"></p><h3 style="text-align: left;">Buffer - Tampon Alanı Hesaplama</h3><p style="text-align: left;">Bir geometrinin sınırlarından istediğimiz birim kadar genişletilmiş şekilde yeni bir geometri elde etmek için <b>buffer()</b> metodunu kullanırız. Örneğimizde, sarı ve mavi poligonlardan 30 birim tamponlu daha geniş poligonlar elde edelim. Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/TamponAlanHesaplama.java" target="_blank">TamponAlanHesaplama.java </a>sınıfını çalıştırarak görselleştirebilirsiniz. </p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">325</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">90</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates2 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">400</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">)};</span>
Polygon maviPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
Polygon sariPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates2<span style="color: #333333;">);</span>
Polygon tamponluSariPoligon <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Polygon<span style="color: #333333;">)</span> sariPolygon<span style="color: #333333;">.</span><span style="color: #0000cc;">buffer</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">30</span><span style="color: #333333;">);</span>
Polygon tamponluMaviPoligon <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Polygon<span style="color: #333333;">)</span> maviPolygon<span style="color: #333333;">.</span><span style="color: #0000cc;">buffer</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">30</span><span style="color: #333333;">);</span>
</pre></div><p> </p><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd1r9bJiQeW9zL3Rpo6TKuAlDeUPyPvR8ENyHwPG5lF9F7-yeCgsHG7-758MOf0QhZu-rIe71xt_t-ZO4e4BEZ6pvl2bUv-H1-bKmbbAnp3aImq1R2wvUXA_ZktQMt327zsSybgNcFORM/s447/tamponlu_alan_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Tamponlu Alan Hesaplama (Buffer)" border="0" data-original-height="447" data-original-width="441" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd1r9bJiQeW9zL3Rpo6TKuAlDeUPyPvR8ENyHwPG5lF9F7-yeCgsHG7-758MOf0QhZu-rIe71xt_t-ZO4e4BEZ6pvl2bUv-H1-bKmbbAnp3aImq1R2wvUXA_ZktQMt327zsSybgNcFORM/w395-h400/tamponlu_alan_hesaplama.png" title="Tamponlu Alan Hesaplama (Buffer)" width="395" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Tamponlu Alan Hesaplama (Buffer)</td></tr></tbody></table> <br /><p></p><p style="text-align: left;">Önceki Bölümler<br /></p><ol style="text-align: left;"><li> <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">JTS CBS Kütüphanesi Rehberi 1 - Geometri Modeli</a></li><li><a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-2-geometrik.html" target="_blank">JTS CBS Kütüphanesi Rehberi 2 - Geometrik İlişki Hesaplamaları </a></li></ol><p>Sonraki Bölümler:</p><p class="post-title entry-title" itemprop="name" style="text-align: left;"><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-4-delaunay-triangulation-voronoi-convex-hull.html " target="_blank">JTS CBS Kütüphanesi Rehberi 4 - Delaunay Üçgenleme, Voronoi Diyagram, Convex Hull </a></p><p class="post-title entry-title" itemprop="name" style="text-align: left;"><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-5-quadtree-nedir-java-ornek.html" target="_blank">JTS CBS Kütüphanesi Rehberi 5 - Quadtree Nedir? Java'da Örnek Kullanım</a></p><p class="post-title entry-title" itemprop="name" style="text-align: left;"><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-6-douglas-peucker-simplifier.html" target="_blank">JTS CBS Kütüphanesi Rehberi 6 - Douglas Peucker Geometri Basitleştirme ve Yoğunlaştırma </a> </p><p> </p><p><a href="https://play.google.com/store/books/details?id=4ClVEAAAQBAJ" target="_blank">Download as E-book PDF</a> <br /></p><p><br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-12332136685930291042021-03-19T13:12:00.008-07:002021-07-05T14:43:19.270-07:00Mühendis Özlü Sözleri<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3RRxrhFrX229yt4TeSCw0Mh3YkDSCLoc-to4vWNjqZT2imzvAEDVielpsiSqA_lqeuKA4llB59oThmdnjPg9Ysc42G0J9o2hJdltCxNNx_X0gaanYsZIR6z5xCgW_63mJ4d5zKQIjGLU/s1068/u%25C3%25A7aklar.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1068" data-original-width="1068" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3RRxrhFrX229yt4TeSCw0Mh3YkDSCLoc-to4vWNjqZT2imzvAEDVielpsiSqA_lqeuKA4llB59oThmdnjPg9Ysc42G0J9o2hJdltCxNNx_X0gaanYsZIR6z5xCgW_63mJ4d5zKQIjGLU/w400-h400/u%25C3%25A7aklar.jpg" width="400" /> </a></p><br /><p> <br />1. “Mühendisler problem çözmeyi severler. Eğer ortada çözülecek problem yoksa, kendi elleriyle oluştururlar."<br />- Scott Adams <br /><br />2. “Mükemmellik, ekleyecek birşey kalmadığında değil, çıkarak birşey kalmadığında elde edilir.”<br />- Antoine de Saint-Exupery<br /><br />3. “Bizim işimizde sorun insanların senin fikirlerini çalmasını engellemek değildir, tam aksine fikirlerinizi çalmalarını sağlamaktır!”<br />- Howard Aiken<br /><br />4. “Matematik benim tutkum, mühendislik ise mesleğim.”<br />- Wilfred James Dolor<br /><br />5. “Herhangi bir aptal ayakta duran bir köprü inşa edebilir, ancak sadece bir mühendis ancak zar zor ayakta duran bir köprü yapabilir.”<br />- Anonim<br /><br />6. “İnsan ayağı tam bir mühendislik harikası ve sanat eseridir.”<br />- Leonardo da Vinci<br /><br />7. “Ne kadar az hareketli parça, o kadar iyi." "Gerçekten. Mühendislik alanında bundan daha doğru bir söz henüz söylenmedi.”<br />- Christian Cantrell<br /><br />8. “Birşeylerin nasıl çalıştığını gerçekten öğrenmek istiyorsanız, o şeyi dağılıp parçalanırken inceleyin.”<br />- William Gibson <br /><br />9. “Elli kişi tarafından daha iyi yapılamayacak, beş yüz kişilik bir mühendislik ekibi tarafından yapılan bir işi hiç görmedim.”<br />- C. Gordon Bell<br /><br />10. “İnsanların tamamen kusursuz bir şey tasarlamaya çalışırken yaptıkları yaygın bir hata, tamamen aptalların zekasını hafife almaktır.”<br />- Douglas Adams<br /><br />11. “Yaptığınız her şeyde mükemmellik için çabalayın. Var olanın en iyisini alın ve daha iyi hale getirin. Var olmadığı zaman, onu tasarlayın.”<br />- Sir Henry Royce<br /><br />12. “Normal insanlar, kırılmazsa tamir edilmeyeceğine inanırlar. Mühendisler, kırılmazsa henüz yeterli özelliğe sahip olmadığına inanırlar.”<br />- Scott Adams<br /><br />13. “Birinci mühendislik kuralı; prototiplere dikkat edin. Bununla birlikte, kendi özgün iş yapış şekline sahip olmayan bir mühendis tarafından yapılan her şeyden kaçının.”<br />- Simon R. Green<br /><br />14. “İyi fikirlere sahip olmanın püf noktası, görkemli bir izolasyon içinde oturup büyük düşünceler düşünmeye çalışmak değildir. İşin püf noktası masaya daha fazla parça almaktır.”<br />- Steven Johnson<br /><br />15. “John Kobak şöyle der: Herhangi bir şey öğrenmenin yolu, bir şeyin başarısız olması ve bir daha nasıl başarısız olamayacağını anlamanızdır.”<br />- Robert S. Arrighi<br /><br />16. “İmalat, parçaları bir araya getirmekten daha fazlasıdır. Fikirler ortaya koymak, temel ilkeleri test etmek ve mühendisliğin yanı sıra son montajı mükemmelleştirmektir."<br />- James Dyson<br /><br />17. “Garbolojinin kötü kokulu alanının roket bilimi, petrol keşfi veya beyin cerrahisinin popülaritesine ulaşmamış olması şaşırtıcı değildir."<br />- Hans Y. Tammemagi<br /><br />18. “Tamamladığımız projeler bildiklerimizi gösteriyor - gelecek projeler ne öğreneceğimize karar veriyor.”<br />- Dr. Mohsin Tiwana<br /><br />19. “Vaktimi yüksek konseptli şeyler hakkında insanları kandırmakla harcamıyorum; Zamanımı mühendislik ve üretim problemlerini çözmek için harcıyorum.”<br />- Elon Musk<br /><br />20. “İyi bir bilim adamı, özgün fikirleri olan kişidir. İyi bir mühendis, mümkün olduğunca az fikirle çalışan bir tasarım yapan kişidir.”<br />- Freeman Dyson</p><p>21. “Benim gibi daha fazla mühendis teknolojiden nefret etseydi dünya
daha iyi bir yer olurdu. Tasarladığım şeyleri, başarılı olursam kimse
fark etmeyecek. İşler sadece işe yarayacak ve kendi kendini yönetecek.”<br />- Radia Pearlman <br /><br />22. “İyimser için bardağın yarısı dolu. Karamsar için bardağın yarısı boş. Mühendis için bardak, olması gerekenden iki kat daha büyük."<br />- Anonim<br /><br />23. “Gençlerin tüm insanlık için, daha iyi bir yarın için, bilim ve mühendislikle ilgilenmelerini sağlamaktan daha güçlü bir şekilde inandığım hiçbir şey yok.”</p><p> - Bill Nye<br /><br />24. “Ama şunu unutma, evlat... Uçaklar savaş için var olmadılar. Para kazanmak için de değiller. Uçaklar güzel rüyalardır. Mühendisler hayalleri gerçeğe dönüştürürler."<br />- Hayao Miyazaki<br /><br />25. “Genellikle imkansız olduğunu düşündüğümüz şeyler basit mühendislik problemleridir... Bunları engelleyen fizik yasası yoktur.”<br />- Michio Kaku<br /><br />26. “Başlangıçta bir mühendis olmam gerekiyordu, ancak yaratıcı enerjimi, amaç olarak iğrenç bir sermaye kazancı ile günlük yaşamı daha da rafine hale getiren şeylere harcamak zorunda kalma düşüncesi benim için dayanılmazdı.”<br />- Albert Einstein<br /><br />27. “En önemli şey, en önemli şeyin en önemli şey olarak kalmasını sağlamaktır.”<br />- Donald P. Coduto<br /><br />28. “Elektronları keşfetmek ve hareketlerini yöneten denklemleri bulmak heyecan vericidir; ama bu prensipleri elektrikli konserve açacakları tasarlamak için kullanmak sıkıcı. Şimdilerde artık sadece konserve açacakları var.”<br />- Neal Stephenson<br /><br />29. “Uçaklar bilim tarafından değil, tersine sanat tarafından tasarlanmıştır. Mühendisliğin bilim olmadan da yapabileceğini söylemek istemiyorum, aksine bilimsel temellere dayanmaktadır, ancak bilimsel araştırma ile mühendislik ürünü arasında mühendisin sanatı tarafından kapatılması gereken büyük bir boşluk vardır.”<br />- British Engineer to the Royal Aeronautical Society, 1922.<br /><br />30. “Mükemmel bir köprü, bir milletin ihtişamını ve dehasını tanıtmaya hizmet etmesi gereken büyük bir anıttır; kişi kendini mimari olarak mükemmelleştirme çabalarıyla meşgul etmemelidir. Çünkü zevk her zaman değişime açıktır. Ancak her zaman yapısında ve dekorasyonunda uygun olan sağlamlık karakterini muhafaza etmeye çalışmalıdır.”<br />- Jean Peronnet<br /><br />31. “Mühendis, rakamlarla arası iyi olan, ancak bir muhasebeci kişiliğine sahip olmayan kişidir.”<br />- Anonim<br /><br />32. “Mimarlar ve mühendisler, halkın rızası, halkın onayı ve çoğu zaman kamu parasıyla kendi anıtlarını inşa ettikleri için en şanslı insanlar arasındadır.”<br />- John Prebble<br /><br />33. “Mühendislik, tamamen anlamadığımız malzemeleri, doğru bir şekilde değerlendiremeyeceğimiz kuvvetlere dayanacak şekilde kesin olarak analiz edemeyeceğimiz şekillere dönüştürme sanatıdır, öyle ki halkın cehaletimizin kapsamından şüphelenmek için hiçbir nedeni yoktur.”<br />- Dr. AR Dykes</p><p> </p><p>34. “Mühendislik, bazı bilinen ihtiyaçları karşılamak için çevremizdeki fiziksel dünyayı dönüştüren herhangi bir yapının tasarımını ve yapımını düzenleme çabasını ifade eder.”<br />- G.F.C. Rogers<br /><br />35. “Mühendislik ... kabaca ama yetersiz olmayan bir şekilde tanımlayacak olursak, herhangi bir beceriksizin bir şekilde iki dolarla yapabileceği bir şeyi bir dolarla daha iyi yapma sanatıdır.”<br />- Arthur Mellen Wellington<br /><br />36. “ Mühendisler ... sadece teknisyen değildir ve insana ve medeniyetin ilerlemesine fayda sağlamayı vaat etmeyen hiçbir projeye onay vermemeli veya isimlerini ödünç vermemelidir.”<br />- John Fowler<br /><br />37. “Mühendisler ... insanüstü değildirler. Varsayımlarında, hesaplamalarında, sonuçlarında hatalar yaparlar. Hatalar yapmaları affedilebilir olduğu gibi onları yakalamaları da beklenir. Bu nedenle, modern mühendisliğin özü, sadece kişinin kendi işini kontrol edebilmesi değil, aynı zamanda işini kontrol ettirmesi ve başkalarının çalışmalarını kontrol edebilmesidir.”<br />- Henry Petroski<br /><br />38. “Hayallerden gelen vizyonu alıp bilim ve matematiğin büyüsünü uygulayarak, mesleğimin mirasını ve doğanın malzemeleri hakkındaki bilgilerimi bir tasarım oluşturmak için birleştiriyorum.”<br />- Anonim</p><p><br />39. “Deneyim sadece teoriyi doğrulamaya hizmet etmekle kalmaz, aynı zamanda onu bozmadan ondan farklılık gösterir, teorinin ulaşamadığı yeni gerçeklere götürür.”<br />- Dalembert<br /><br />40. “Bir tünel hattının döşenmesinden nihai tamamlanmasına kadar, iş ya proje sahiplerinin pahasına yapılmış bir dizi deney ya da önceki deneyimin sonuçlarının bir dizi mantıklı uygulaması olabilir.”<br />- H.S. Drinker<br /><br />41. “İnşaat mühendisliğini tercih edin, çünkü inşaat mühendisliği size insanları yönetme konusunda en çok şeyi öğreten mühendislik dalıdır. İnsanları yönetmek çok, çok yararlı ve neredeyse ne yaptığınıza bakılmaksızın faydalı olan bir beceridir.”<br />- Sir John Harvey Jones<br /><br />42. “Başarısız olmadım ama ampul yapmamak için 1000 yol buldum.”<br />- Thomas Edison<br /><br />43. “Köprülerin inşasında uyulacak kuralların veya koşulların belirlenmesine karşıyım ki, bugünün önyargılarını veya hatalarını kanun olarak kaydetmek veya kayıt altına almak yarınki iyileşmenin önünü tıkamış utanç verici bir şey olabilir.”<br />- Isambard Kingdom Brunel<br /><br />44. “Mühendislik tarihi gerçekten de bozulmaların ve bu bozulmalardan öğrenmenin tarihidir. Üniversitede bana şu öğretilmişti ki 'mühendis en çok hurdalıkta öğrenir.”<br />- C.A. Claremont, Spanning Space<br /><br />45. “Mühendislere dikkat etmek gerekir. Dikiş makinesiyle başlarlar, atom bombasıyla bitirirler.”<br />- Marcel Pagnol, Critiques des Critiques<br /><br /><br />46. “Yıllar geçtikçe insanlar başta bilseler bile bunu hangi mühendisin yaptığını unuturlar. Veya bir politikacı ona kendi adını verir. Ya da onu finanse etmek için diğer insanların parasını kullanan bir sponsorun adı ile anarlar. Ancak mühendisin kendisi, sadece birkaç mesleğin bilebileceği tatminlerle geçmiş başarı zincirlerine bakar. Ve profesyonel meslektaşlarının övgüsü, istediği tek ödüldür.”<br />- Herbert Hoover<br /><br />47. “Mühendislik veya teknoloji, daha önce var olmayan şeylerin yapımıdır, oysa bilim, uzun süredir var olan şeylerin keşfedilmesidir."<br />- David Billington<br /><br />48.“Yanlış gidebilecek bir şey ile yanlış gitmesi mümkün olmayan bir şey arasındaki en büyük fark, yanlış gitmesi mümkün olmayan bir şey ters gittiğinde, genellikle ulaşıp tamir etmenin imkansız hale gelmesidir.”<br />- Douglas Adams<br /><br />49. “Dünyanın refahı büyük ölçüde mühendislerin çalışmasına bağlıdır. Mesleğin büyük bir geleceği ve sınırsız kapsamı var; Her ülkede her türden yeni eser isteniyor ve istenecek ve hayal gücü ve hevese sahip genç bir adam için daha çekici bir meslek düşünemiyorum. Bilimsel bilgi kadar hayal gücü de gereklidir.”<br />-Sir William Halcrow<br /><br />50. “Pek çok yönden köprü kurma hikayesinin medeniyet hikayesi olduğuna şüphe yok. Bununla, bir halkın ilerlemesinin önemli bir bölümünü kolaylıkla ölçebiliriz.”<br />- Franklin D. Roosevelt<br /><br />51. “Mühendislik bilimden oldukça farklıdır. Bilim adamları doğayı anlamaya çalışır. Mühendisler doğada olmayan şeyler yapmaya çalışırlar. Mühendisler buluşu zorlarlar.”<br />- Yuan-Cheng Fung<br /><br />52. “Mühendisler ve miktar ölçme uzmanları estetiği tartıştıklarında ve mimarlar vinçlerin ne yaptığını araştırdıklarında doğru yolda olacağız demektir.”<br />- Ove Arup<br /><br />53. “Mühendisin hayatı boyunca yaptığı iş, doğal güçlerin sistematik olarak uygulanmasından ve doğal kaynakların insan hizmetinde sistematik olarak geliştirilmesinden oluşur.”<br />- Harry Walter Tyler <br /><br />54. “Bilim adamı yeni bir malzeme veya enerji türü keşfeder ve mühendis bunun yeni bir kullanım alanını keşfeder.”<br />- Gordon Lindsay Glegg<br /><br />55. Bir bilim adamı yeni bir yıldız keşfedebilir ama yıldız yapamaz. Bir mühendisten bunu kendisi için yapmasını istemesi gerekirdi.”<br />- Gordon Lindsay Glegg<br /><br />56. “Mühendislik, yürüyen bir ansiklopedi gibi sadece bilmek ve bilgili olmak değildir; mühendislik yalnızca analiz değildir; mühendislik sadece var olmayan mühendislik problemlerine zarif çözümler getirme kapasitesine sahip olmak değildir; mühendislik, teknolojik değişimin gücünü organize etme sanatını icra etmektir… Mühendisler, bilim ve toplum arasında bir yerde çalışırlar.”<br />- Gordon Stanley Brown<br /><br />57. “Binalarımızı şekillendiriyoruz, sonra onlar bizi şekillendiriyor.”<br />- Winston Churchill<br /><br />58. “Mühendislik, insanlığın kullanımı ve rahatlığı için doğadaki büyük güç kaynaklarını yönlendirme sanatıdır.”<br />- Thomas Tredgold<br /><br />59. “Mühendislik, refah üretmek için doğal kaynakların verimli kullanımına yönelik bilimin profesyonel ve sistematik uygulamasıdır."<br />- Theodore Jesse Hoover<br /><br />60. “Mühendisler iş dünyasında iş insanlarından daha mı iyidir? Tartışmalı. İş adamları kesinlikle daha büyük evlere sahipler, daha süslü arabalar kullanıyorlar, daha güzel kıyafetler giyiyorlar ve daha iyi görünen arkadaşları var. Mühendisler bu tür parayı harcayacak zaman yönetimi becerilerinden yoksundur. Mümkün olan en hızlı ve en verimli şekilde en fazla parayı kazanmanın yollarını bulmak için tüm zamanlarını harcıyorlar. Ve sonra anladıklarında süreci optimize ediyorlar.”<br />- Raul Perez<br /><br />61. “Kimse hatalarla öğrenmek istemez, ancak başarılardan son teknolojinin ötesine geçecek kadar öğrenemeyiz.”<br />- Henry Petroski<br /><br />62. “Bilim hepimizi şaşırtabilir ve büyüleyebilir ama dünyayı değiştiren mühendisliktir.”<br />- Isaac Asimov<br /><br />63. “Bilim adamları dünyayı olduğu gibi incelerler, mühendisler hiç olmamış dünyaları ortaya çıkarırlar.”<br />- Theodore von Karman<br /><br />64. “Medeniyetin öyküsü, bir bakıma mühendisliğin öyküsüdür - doğanın güçlerini insanın iyiliği için çalıştırmaya yönelik o uzun ve çetin mücadeledir.”<br />- Lyon Sprague DeCamp<br /> </p><p>65. “Erkekler köprüler kurar ve çöllere demiryolları atarlar, ancak yine de bir düğmeyi dikmenin kendilerinin ötesinde olduğunu başarılı bir şekilde iddia ederler.”<br />- Heywood Broun<br /><br />66. “İdeal mühendis bir karışımdır… O bir bilim adamı değildir, matematikçi değildir, sosyolog veya yazar değildir, ancak mühendislik problemlerinin çözümünde bu disiplinlerden herhangi birinin veya tümünün bilgi ve tekniklerini kullanabilir.”<br />- N.W. Dougherty<br /><br />67. “Mühendislik, insanın kullanımı için doğa tarafından sağlanan ve depolanan, enerji, kinetik ve potansiyeli koruma bilimidir. Bu enerjiyi en iyi şekilde kullanmak mühendislik işidir, böylece mümkün olan en az israf yapılabilir.”<br />- William A. Smith<br /> </p><p>68. “Yeni ekonomik dünya hakkında bildiğimiz tek şey bize mühendis yetiştiren ulusların avukat yetiştirenlere üstün geleceğini söylüyor. Şimdiye kadar hiçbir millet, büyüklüğe giden yolu dava etmedi.”<br />- Richard Lamm<br /><br />69. “Görüyorsunuz, amacım mühendislik dünyasını karıştırmak değil, sadece güzel bir sanat eseri ortaya koymaktı.”<br />- Kit Williams<br /><br />70. “İyi bir mühendis tersten düşünür ve kendisine önerdiği bileşenlerin ve sistemlerin biçimsel sonuçlarını sorar.”<br />- Helmut Jahn<br /><br />71. “Mühendislik dehasının büyük zaferleri - lokomotif, makas köprüsü, çelik ray - ... mühendislikten ziyade bir icattır.”<br />- Arthur Mellen Wellington<br /> </p><p>72. “Bir teori, tanımlayıcı olasılıklar açısından o kadar zengin olabilir ki, herhangi bir veriye uyacak şekilde yapılabilir.”<br />- Phillip Johnson-Laird<br /><br />73. “Herhangi bir tasarım aşamasında mühendisin ilk sorunu, sorunun gerçekte ne olduğunu keşfetmektir.”<br />- Anonim<br /><br />74. “Mevcut gerçeklikle savaşarak bir şeyleri asla değiştiremezsiniz. Bir şeyi değiştirmek için mevcut modeli geçersiz kılan yeni bir model oluşturun.”<br />- Buckminster Fuller<br /><br />75. “Mühendislik zihni harekete geçirir. Çocuklar kolayca sıkılır. Dışarı çıkıp ellerini kirletmek zorundalar: bir şeyler yapmak, bir şeyleri parçalamak, bir şeyleri düzeltmek. Okullar bunu sunabildiğinde, bir hayat mühendisiniz olacak.”<br />- Bruce Dickinson<br /><br />76. “Mühendislerin zorlamaları olmasaydı, insanlık tekerleği asla görmezdi, onun yerine yamuk yaygınlaşırdı. Çünkü pazarlamadaki biri herkesi büyük bir frenleme yeteneğine sahip olduğuna ikna ederdi.”<br />- Scott Adams<br /><br />77. “O zamanlarda (1909) baş mühendis neredeyse her zaman aynı zamanda baş test pilotuydu. Bu, havacılığın erken dönemlerinde zayıf mühendisliği ortadan kaldırmaya yarayan bir şanstı.”<br />- Igor Sikorsky<br /><br />78. “Sanırım bana en çok sorulan soru şu: "O kapsülün içinde oturup geri sayımı dinlerken nasıl hissettin?" Bunun cevabı kolay. Fırlatmaya hazır bir şekilde hepsi bir hükümet sözleşmesindeki en düşük teklif veren tarafından inşa edilen iki milyon parçanın üzerinde oturduğunuzu bilseniz tam olarak nasıl hissedeceğinizi hissettim.”<br />- John Glenn<br /><br />79. “Biz, bilmeyenlerin önderliğindeki isteksizler, nankör için imkansız olanı yapıyoruz. Çok uzun zamandır o kadar çok şey yaptık ki, çok az şeyle, artık hiçbir şey yapmadan her şeyi yapmaya yetkin durumdayız."<br />- Anonim<br /><br />80. “Ne zaman bir iş yapıp yapamayacağınız sorulduğunda, onlara 'Kesinlikle yapabilirim!' Deyin Sonra çalışın ve nasıl yapılacağını öğrenin.”<br />- Theodore Roosevelt<br /><br />81. “Mühendis, filozof ile teknisyen arasında bir arabulucudur ve iki yabancı arasındaki bir tercüman gibi her ikisinin de dilini, dolayısıyla hem pratik hem de teorik bilgiye sahip olmanın mutlak gerekliliğini anlamalıdır.”<br />- Henry Palmer<br /><br />82. “Bir problem üzerinde çalışırken asla güzelliğini düşünmem ama bitirdiğimde çözüm güzel değilse yanlış olduğunu bilirim.”<br />- R. Buckminster Fuller<br /><br />83. "Bilim adamı, anlık bir sonucu hedeflemez. Gelişmiş fikirlerinin hemen ele alınacağını beklemez. Onun işi çiftçi gibidir. Görevi, gelecek olanların temelini atmak ve yolu göstermektir. O yaşar, çalışır ve umut eder.”<br />- Nikola Tesla<br /><br />Daha fazlası için :</p><p><a href="https://www.muratoksuzer.com/2018/02/yazlmc-ozlu-sozleri.html" target="_blank">Yazılımcı Özlü Sözleri tıklayın.</a></p><p><a href="https://www.muratoksuzer.com/2020/07/calismak-ve-is-ile-alakali-atasozleri-deyimler.html.html" target="_blank">Çalışmak ve İş ile Alakalı Atasözleri ve Deyimler </a><br /><br /></p><br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-1026923242030663032021-03-12T23:36:00.024-08:002021-12-25T04:05:40.016-08:00JTS CBS Kütüphanesi Rehberi 2 - Geometrik İlişki Hesaplamaları<p>Merhabalar. JTS rehberimizin bir <a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">önceki bölümünde</a> geometrik modelleri
tanımıştık. Şimdi ise kesişir mi, içerir mi gibi ilişki hesaplamalarının nasıl
yapıldığını göreceğiz.</p><p>Geometri modeli kapsamındaki tüm nesneler
<b>Geometry </b>sınıfından türemektedir. Bu sınıfın bize sunduğu bazı hesaplama
metodlarını inceleyeceğiz.</p><h3 style="text-align: left;">Görselleştirme</h3><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW8CuKTivcfYGa0hCTtj69tszWnklTGrZd5oj2vz3zUwhrWGFVsAvtZta-9b2D4aXbm-SIbTQOWQ-UBkKqUtmUi6rOrLzdZLky_pvWb0TpDdRi14k32krhWTR40y14Lc1Y3VnnPYHG49s/s451/kapsiyor_contains_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Geometrik Kapsama Hesaplama" border="0" data-original-height="410" data-original-width="451" height="364" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW8CuKTivcfYGa0hCTtj69tszWnklTGrZd5oj2vz3zUwhrWGFVsAvtZta-9b2D4aXbm-SIbTQOWQ-UBkKqUtmUi6rOrLzdZLky_pvWb0TpDdRi14k32krhWTR40y14Lc1Y3VnnPYHG49s/w400-h364/kapsiyor_contains_hesaplama.png" title="Geometrik Kapsama Hesaplama" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Geometrik Kapsama Hesaplama</td></tr></tbody></table><br /><p>Tüm bu bilgiler görselleştirilmez ise anlaşılması zor olabilirdi. Bu nedenle basit bir Swing arayüzü ile yaptığımız hesaplamaları bir JPanel üzerine çizmek faydalı olacaktır. Bu yazıdaki tüm denemeleri çalıştırıp görselleştirebileceğiniz kodların bulunduğu projeye <a href="https://github.com/mokszr/jts-egitim" target="_blank">GitHub'da şuradan ulaşabilirsiniz.</a> </p><p>paintComponent metodunu override ettiğimiz JPanel'den türeyen JTSGorsellestirmePanel sınıfında, java.awt.Graphics nesnesini kullanarak 2D çizimler yapacağız. Yalnız, bu Graphics sınıfının çizim metodları integer türünde değerler almakta. JTS hesaplamaları ise double değerler de dönebilmektedir. Bu nedenle görselleştirmeler %100 gerçek noktalara oturmayıp hafif hassasiyet kaybı yaşanmış şekilde çizilebilecektir.</p><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgjZ6DCEhTJ77L_PqnhvBIcxkbKhfstA0CRczJ0clFE0dX_MbT2a5DHIQOMrFX2Oks1chDuL74h79bqP_FmVECIyW0ktd55L7an_VnipBAlr6tc8sAirsVxR1lhp82dKy0buMEpcWDMtA/s680/JTSGorsellestirmePanel_Java.png" style="margin-left: auto; margin-right: auto;"><img alt="JTSGorsellestimePanel.java" border="0" data-original-height="680" data-original-width="523" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgjZ6DCEhTJ77L_PqnhvBIcxkbKhfstA0CRczJ0clFE0dX_MbT2a5DHIQOMrFX2Oks1chDuL74h79bqP_FmVECIyW0ktd55L7an_VnipBAlr6tc8sAirsVxR1lhp82dKy0buMEpcWDMtA/w308-h400/JTSGorsellestirmePanel_Java.png" title="JTSGorsellestimePanel.java" width="308" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">JTSGorsellestimePanel.java</td></tr></tbody></table> <p></p><p>Her görselleştirme için farklı DrawingCommand nesnelerini bu panele draw command olarak ekleyecek ve istediğimiz çizimleri ekranda görebileceğiz. </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcY_WwY07frZAoBiQC6r8TbWAfDIjCbL6eYJahui05C-wgrL2zWzWMzuUELNt5WzBCE6mkydzFMG6Lf6w936o5reKi0USwJQxL5ynAszd186aqhj3hB-RSfI68KPzYDJfKdz9cJZ82cr8/s257/DrawingCommand.png" style="margin-left: auto; margin-right: auto;"><img alt="DrawingCommand.java" border="0" data-original-height="136" data-original-width="257" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcY_WwY07frZAoBiQC6r8TbWAfDIjCbL6eYJahui05C-wgrL2zWzWMzuUELNt5WzBCE6mkydzFMG6Lf6w936o5reKi0USwJQxL5ynAszd186aqhj3hB-RSfI68KPzYDJfKdz9cJZ82cr8/w400-h212/DrawingCommand.png" title="DrawingCommand.java" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">DrawingCommand.java</td></tr></tbody></table><br /><p></p><p></p><p> Örneğin iki LineString'in kesişimini görselleştirdiğimizde ekranda şöyle bir panel göreceğiz.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9Fq-JkfWbqvy_9g3CLvDNgRfzr0oo22s6E-5rnFQjlGa6JTo6fck6ITDr6j6PmnVFup2ggZd_CWuUpOlXsMN0Pb_mGUyycIHuaQOnHN6JTWWluio0wLL7iyfBlGoxJtQwkrpLhYKiLzs/s455/kesisim_lineString.png" style="margin-left: 1em; margin-right: 1em;"><img alt="Kesişim LineString" border="0" data-original-height="455" data-original-width="448" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9Fq-JkfWbqvy_9g3CLvDNgRfzr0oo22s6E-5rnFQjlGa6JTo6fck6ITDr6j6PmnVFup2ggZd_CWuUpOlXsMN0Pb_mGUyycIHuaQOnHN6JTWWluio0wLL7iyfBlGoxJtQwkrpLhYKiLzs/w394-h400/kesisim_lineString.png" title="Kesişim LineString" width="394" /></a></div><p></p><p></p><p></p><h3 style="text-align: left;">Area - Alan</h3><p style="text-align: left;">Bir üçgeni temsil edecek Polygon nesnesi oluşturup <b>getArea()</b> metodu ile alanını hesaplatalım. Örnek projemizde <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/AlanHesaplama.java" target="_blank">AlanHesaplama.java</a> sınıfını çalıştırarak görselleştirebilirsiniz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">200</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">90</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Polygon polygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> alan <span style="color: #333333;">=</span> polygon<span style="color: #333333;">.</span><span style="color: #0000cc;">getArea</span><span style="color: #333333;">();</span>
</pre></div><p style="text-align: left;"><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW6VdUBnzVQO4mp_7jM6OnuQmvxJH_-000cFELKO4thgZZ4rSwsucmCDstjq-K8wn7FkRsSF_c1e8mgJeB8Z5-xTK5ZtAmC5jembJlDL5PvCE3hC5Jhx7bW9j3Jey5vPK-RHkwbMIwtD4/s447/alan_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Geometrik Alan Hesaplama" border="0" data-original-height="278" data-original-width="447" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW6VdUBnzVQO4mp_7jM6OnuQmvxJH_-000cFELKO4thgZZ4rSwsucmCDstjq-K8wn7FkRsSF_c1e8mgJeB8Z5-xTK5ZtAmC5jembJlDL5PvCE3hC5Jhx7bW9j3Jey5vPK-RHkwbMIwtD4/w400-h249/alan_hesaplama.png" title="Geometrik Alan Hesaplama" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Geometrik Alan Hesaplama</td></tr></tbody></table><h3 style="text-align: left;"></h3><h3 style="text-align: left;"></h3><h3 style="text-align: left;"></h3><h3 style="text-align: left;"></h3><p style="text-align: left;">Tanımladığımız üçgenin koordinatlarından, üçgenin yüksekliğinin 150 - 60 = 90 birim, taban uzunluğunun ise, 200 - 90 = 110 birim olduğu görülüyor. Üçgenin alanı formülünden 90 * 110 /2 = 4950 olarak alanı doğru hesapladığını görebiliyoruz.<br /></p><h3 style="text-align: left;">Length / Perimeter - Uzunluk Çevre</h3><p style="text-align: left;">Bir çizgiyi temsil edecek LineString tanımlayıp uzunluğunu hesaplatalım. Çevre hesaplamak için de bir beşgeni temsil edecek Polygon nesnesi tanımlayıp çevresini hesaplatalım. Örnek projemizdeki <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/UzunlukCevreHesaplama.java" target="_blank">UzunlukCevreHesaplama.java</a> sınıfını çalıştırarak görselleştirebilirsiniz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">200</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">80</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">80</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">40</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">160</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
LineString lineString <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> uzunluk <span style="color: #333333;">=</span> lineString<span style="color: #333333;">.</span><span style="color: #0000cc;">getLength</span><span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> polygonCoordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">160</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">270</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">170</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">330</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">280</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">)};</span>
Polygon polygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>polygonCoordinates<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> poligonCevre <span style="color: #333333;">=</span> polygon<span style="color: #333333;">.</span><span style="color: #0000cc;">getLength</span><span style="color: #333333;">();</span>
</pre></div><p style="text-align: left;"> </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_vKUHpiBU4Y-zFrSe5-eoOzZbqsrou8aP_DR6rO1dNknI16MVVVyj2VwcAKOP_jKeqZANPUrDoP1Oqem3nhb6zB2HPl0l1Se-jFCzReuLfCLv3nriIseIRdfhYO3r_Dloq0adnx4rGnY/s458/uzunluk_cevre_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Uzunluk Çevre Hesaplama" border="0" data-original-height="458" data-original-width="450" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_vKUHpiBU4Y-zFrSe5-eoOzZbqsrou8aP_DR6rO1dNknI16MVVVyj2VwcAKOP_jKeqZANPUrDoP1Oqem3nhb6zB2HPl0l1Se-jFCzReuLfCLv3nriIseIRdfhYO3r_Dloq0adnx4rGnY/w393-h400/uzunluk_cevre_hesaplama.png" title="Uzunluk Çevre Hesaplama" width="393" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Uzunluk Çevre Hesaplama</td></tr></tbody></table><br /><p style="text-align: left;"></p><h3 style="text-align: left;"></h3><h3 style="text-align: left;">Distance / isWithinDistance - Uzaklık, Mesafe İçinde mi</h3><p style="text-align: left;">Bir nokta ve poligon tanımlayalım. Noktanın poligona olan uzaklığını hesaplayalım. Daha sonra bu uzaklığa göre, isWithinDistance metodu ile verdiğimiz mesafe içinde poligon nesnesi var mı kontrolünü yapalım. <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/UzaklikHesaplama.java" target="_blank">UzaklikHesaplama.java</a> sınıfını çalıştırarak sonuçları ekranda görselleştirebilirsiniz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">190</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Polygon polygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
Point point <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPoint</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">));</span>
<span style="color: #333399; font-weight: bold;">double</span> distance <span style="color: #333333;">=</span> polygon<span style="color: #333333;">.</span><span style="color: #0000cc;">distance</span><span style="color: #333333;">(</span>point<span style="color: #333333;">);</span>
DistanceOp op <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> DistanceOp<span style="color: #333333;">(</span>polygon<span style="color: #333333;">,</span> point<span style="color: #333333;">);</span>
Coordinate<span style="color: #333333;">[]</span> nearestPoints <span style="color: #333333;">=</span> op<span style="color: #333333;">.</span><span style="color: #0000cc;">nearestPoints</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">boolean</span> mesafedeMi103 <span style="color: #333333;">=</span> point<span style="color: #333333;">.</span><span style="color: #0000cc;">isWithinDistance</span><span style="color: #333333;">(</span>polygon<span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">103</span><span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">boolean</span> mesafedeMi102 <span style="color: #333333;">=</span> point<span style="color: #333333;">.</span><span style="color: #0000cc;">isWithinDistance</span><span style="color: #333333;">(</span>polygon<span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">102</span><span style="color: #333333;">);</span>
</pre></div><p style="text-align: left;"> </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMjwCxKsN5zTsSg7VvVHP5-x7CuAotK2fLAEyMBGbCxZvYxateoImgzxPojxhHuTiHj_Q34vZ9LxwB8Lpv4j4jiJMK_8U27EFTSqb5sfGLoZUn3JNxjCJnJlnjSUzHj3dS0j25bjBB7_k/s451/uzaklik_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Uzaklık Hesaplama" border="0" data-original-height="358" data-original-width="451" height="318" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMjwCxKsN5zTsSg7VvVHP5-x7CuAotK2fLAEyMBGbCxZvYxateoImgzxPojxhHuTiHj_Q34vZ9LxwB8Lpv4j4jiJMK_8U27EFTSqb5sfGLoZUn3JNxjCJnJlnjSUzHj3dS0j25bjBB7_k/w400-h318/uzaklik_hesaplama.png" title="Uzaklık Hesaplama" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Uzaklık Hesaplama<br /></td></tr></tbody></table><br /><p style="text-align: left;"></p><h3 style="text-align: left;"></h3><h3 style="text-align: left;">Contains / Within - İçeriyor, İçinde</h3><p style="text-align: left;">Bir önceki örnekte kullandığımız poligonun içinde olan ve dışında olan iki nokta oluşturalım. <b>contains</b> metodu ile içeriyor kontrolü yapalım. <b>within </b>metodu ile de içinde mi kontrolü yapalım. <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/IceriyorHesaplama.java" target="_blank">IceriyorHesaplama.java</a> sınıfını çalıştırarak sonuçları ekranda görselleştirebilirsiniz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">190</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Polygon polygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
Point point <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPoint</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">));</span>
Point point2 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPoint</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">85</span><span style="color: #333333;">));</span>
<span style="color: #333399; font-weight: bold;">boolean</span> poligonPoint1iIceriyorMu <span style="color: #333333;">=</span> polygon<span style="color: #333333;">.</span><span style="color: #0000cc;">contains</span><span style="color: #333333;">(</span>point<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">boolean</span> poligonPoint2yiIceriyorMu <span style="color: #333333;">=</span> polygon<span style="color: #333333;">.</span><span style="color: #0000cc;">contains</span><span style="color: #333333;">(</span>point2<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">boolean</span> point1PoligonunIcindeMi <span style="color: #333333;">=</span> point<span style="color: #333333;">.</span><span style="color: #0000cc;">within</span><span style="color: #333333;">(</span>polygon<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">boolean</span> point2PoligonunIcindeMi <span style="color: #333333;">=</span> point2<span style="color: #333333;">.</span><span style="color: #0000cc;">within</span><span style="color: #333333;">(</span>polygon<span style="color: #333333;">);</span>
</pre></div><p style="text-align: left;"> </p><p style="text-align: left;"></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9VVqTS_ODx8OIdbXwCerbH6KCOTZMQW_FQSIN0-o9knvrvd87gY_x580qdBfS59F223g9F5EKjtM1o7aQ2sIjRO-14JjqhYZv2DUAp0WpJQsyLzST8MbJaZQb4prYE5zYWmjmp4FVZwE/s456/icerir_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="İçerir Hesaplama" border="0" data-original-height="364" data-original-width="456" height="319" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9VVqTS_ODx8OIdbXwCerbH6KCOTZMQW_FQSIN0-o9knvrvd87gY_x580qdBfS59F223g9F5EKjtM1o7aQ2sIjRO-14JjqhYZv2DUAp0WpJQsyLzST8MbJaZQb4prYE5zYWmjmp4FVZwE/w400-h319/icerir_hesaplama.png" title="İçerir Hesaplama" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">İçerir Hesaplama</td></tr></tbody></table><br /><p></p><h3 style="text-align: left;"></h3><h3 style="text-align: left;">Covers / CoveredBy - Kapsıyor, Tarafından Kapsanıyor</h3><p style="text-align: left;">Bir dörtgen ve dörtgenin içinde bulunacak şekilde bir üçgen tanımlayalım. <b>covers </b>metodu ile dörtgenin üçgeni kapsadığını, <b>coveredBy </b>metodu ile de üçgenin dörtgen tarafından kapsandığını gösterelim. <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/KapsiyorHesaplama.java" target="_blank">KapsiyorHesaplama.java </a>sınıfını çalıştırarak sonuçları ekranda görselleştirebilirsiniz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">200</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">190</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">200</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">)};</span>
Polygon polygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
Coordinate<span style="color: #333333;">[]</span> dortgenCoordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">80</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">370</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">90</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">370</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">),</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">)</span> <span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">80</span><span style="color: #333333;">)};</span>
Polygon dortgen <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>dortgenCoordinates<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">boolean</span> dortgenPoligonuKapsiyorMu <span style="color: #333333;">=</span> dortgen<span style="color: #333333;">.</span><span style="color: #0000cc;">covers</span><span style="color: #333333;">(</span>polygon<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">boolean</span> poligonDortgenTarafindanKapsaniyorMu <span style="color: #333333;">=</span> polygon<span style="color: #333333;">.</span><span style="color: #0000cc;">coveredBy</span><span style="color: #333333;">(</span>dortgen<span style="color: #333333;">);</span>
</pre></div><p style="text-align: left;"><br /> </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn3PZUX023gdjWmDeJBpSZpWiEU-xO04KCDKQVZ23x1khpO5T_pZUEzeqQHNN9yFwWfC0gQ3B-tOcASH5VqFoVXMa3egg5Ykok2EnZLHR_PkNuoUIZ_otw8TPlCA3EHf0qyosgK18Yq48/s451/kapsama_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Kapsama Hesaplama" border="0" data-original-height="410" data-original-width="451" height="364" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn3PZUX023gdjWmDeJBpSZpWiEU-xO04KCDKQVZ23x1khpO5T_pZUEzeqQHNN9yFwWfC0gQ3B-tOcASH5VqFoVXMa3egg5Ykok2EnZLHR_PkNuoUIZ_otw8TPlCA3EHf0qyosgK18Yq48/w400-h364/kapsama_hesaplama.png" title="Kapsama Hesaplama" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Kapsama Hesaplama</td></tr></tbody></table><br /><p style="text-align: left;"></p><p></p><h3 style="text-align: left;">Intersects / Disjoint - Kesişir, Ayrık</h3><p>3 adet çizgi çizelim ve bunların ilk ikisi kesişiyor olsun. <b>intersects </b>metodu ile çizgi 1 ve çizgi 2'nin kesiştiğini, çizgi 3'ün kesişmediğini gösterelim. <b>disjoint </b>metodu ile de çizgi 3 ve çizgi 1'in ayrık olduğunu gösterelim. <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/KesisimHesaplama.java" target="_blank">KesisimHesaplama.java </a>sınıfını çalıştırarak sonuçları ekranda görselleştirebilirsiniz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">50</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">)</span> <span style="color: #333333;">};</span>
LineString cizgi1 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
LineString cizgi2 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">80</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">40</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">30</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">)</span> <span style="color: #333333;">});</span>
<span style="color: #333399; font-weight: bold;">boolean</span> cizgi1Cizgi2KesisirMi <span style="color: #333333;">=</span> cizgi1<span style="color: #333333;">.</span><span style="color: #0000cc;">intersects</span><span style="color: #333333;">(</span>cizgi2<span style="color: #333333;">);</span>
Point intersectionPoint <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Point<span style="color: #333333;">)</span> cizgi1<span style="color: #333333;">.</span><span style="color: #0000cc;">intersection</span><span style="color: #333333;">(</span>cizgi2<span style="color: #333333;">);</span>
LineString cizgi3 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">75</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">170</span><span style="color: #333333;">)</span> <span style="color: #333333;">});</span>
<span style="color: #333399; font-weight: bold;">boolean</span> cizgi3Cizgi1AyrikMi <span style="color: #333333;">=</span> cizgi3<span style="color: #333333;">.</span><span style="color: #0000cc;">disjoint</span><span style="color: #333333;">(</span>cizgi1<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">boolean</span> cizgi3Cizgi1KesisirMi <span style="color: #333333;">=</span> cizgi3<span style="color: #333333;">.</span><span style="color: #0000cc;">intersects</span><span style="color: #333333;">(</span>cizgi1<span style="color: #333333;">);</span>
</pre></div><p> </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLbC7AnjPBsAdpoYVuXEt3VkAwqWFHg6yj-W0s-tNUlAmEuYeU2NZ5u1FXKGHjwyfGAUGy4fw229qb6TfFspQMDR37ofQGnAaRJ0zInnGTVoIM43-91GIaxvn1XcPZf4DyRdnJ0EPHaUY/s442/kesisim_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Kesişim Hesaplama" border="0" data-original-height="400" data-original-width="442" height="363" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLbC7AnjPBsAdpoYVuXEt3VkAwqWFHg6yj-W0s-tNUlAmEuYeU2NZ5u1FXKGHjwyfGAUGy4fw229qb6TfFspQMDR37ofQGnAaRJ0zInnGTVoIM43-91GIaxvn1XcPZf4DyRdnJ0EPHaUY/w400-h363/kesisim_hesaplama.png" title="Kesişim Hesaplama" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Kesişim Hesaplama</td></tr></tbody></table><p></p><h3 style="text-align: left;">Crosses - Kesiyor</h3><p style="text-align: left;">Birbirini kesen geometrilerde crosses çağrısı true dönmektedir. <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/KesiyorHesaplama.java" target="_blank">KesiyorHesaplama.java </a>sınıfını çalıştırarak sonuçları ekranda görselleştirebilirsiniz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates1 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">155</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates2 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">)</span> <span style="color: #333333;">};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates3 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">40</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">75</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">)</span> <span style="color: #333333;">};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates4 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">210</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">160</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">)</span> <span style="color: #333333;">};</span>
Polygon poly1 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates1<span style="color: #333333;">);</span>
Polygon poly2 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates2<span style="color: #333333;">);</span>
LineString line1 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span>coordinates3<span style="color: #333333;">);</span>
LineString line2 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span>coordinates4<span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly1.crosses(line1) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly1<span style="color: #333333;">.</span><span style="color: #0000cc;">crosses</span><span style="color: #333333;">(</span>line1<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"-----------------"</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"line1.crosses(poly2) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>line1<span style="color: #333333;">.</span><span style="color: #0000cc;">crosses</span><span style="color: #333333;">(</span>poly2<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"-----------------"</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"line1.crosses(poly1) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>line1<span style="color: #333333;">.</span><span style="color: #0000cc;">crosses</span><span style="color: #333333;">(</span>poly1<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"-----------------"</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly2.crosses(line2) "</span> <span style="color: #333333;">+</span> poly2<span style="color: #333333;">.</span><span style="color: #0000cc;">crosses</span><span style="color: #333333;">(</span>line2<span style="color: #333333;">));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"-----------------"</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"line2.crosses(poly2) "</span> <span style="color: #333333;">+</span> line2<span style="color: #333333;">.</span><span style="color: #0000cc;">crosses</span><span style="color: #333333;">(</span>poly2<span style="color: #333333;">));</span>
</pre></div><p style="text-align: left;"> </p><p style="text-align: left;"></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrVtk79zhTdw8OZUiXmI-TNVlmKqJ4BrdIAhhPKIKZtsVdLYxS60G_mugqP4ND1xywY1FI5hUUJyERHBsY0pic5x83hGiZuuYsf-hjcaUKUrK1TzMJKpwVkCo6lpkgcdeoOpCRmgTOGuc/s454/kesme_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Kesme Hesaplama" border="0" data-original-height="454" data-original-width="446" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrVtk79zhTdw8OZUiXmI-TNVlmKqJ4BrdIAhhPKIKZtsVdLYxS60G_mugqP4ND1xywY1FI5hUUJyERHBsY0pic5x83hGiZuuYsf-hjcaUKUrK1TzMJKpwVkCo6lpkgcdeoOpCRmgTOGuc/w393-h400/kesme_hesaplama.png" title="Kesme Hesaplama" width="393" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Kesme Hesaplama</td></tr></tbody></table><br /><p></p><p style="text-align: left;"></p><h3 style="text-align: left;">Overlaps - Kaplıyor, Örtüşüyor ve Touches - Dokunuyor</h3><p style="text-align: left;"><b>overlaps </b>ve <b>touches </b>metodlarını ortak bir örnekte gösterelim. Sadece köşe noktaları aynı olan, alan olarak birbirinin üstüne düşmeyen geometriler, birbirine dokunuyor demektir. <b>touches </b>çağrıları true döner. Köşe noktalarından da ileri gidip, birbirinin üstüne gelen alanları olan geometriler de örtüşüyor demektir. <b>overlaps </b>çağrıları true döner. <a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/DokunmaHesaplama.java" target="_blank">DokunmaHesaplama.java </a>sınıfındaki görselleştirmeyi incelediğimizde daha anlaşılır olacaktır. </p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates1 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">110</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">155</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates2 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">155</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">250</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">310</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">40</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">155</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates3 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">300</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">180</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">120</span><span style="color: #333333;">)</span> <span style="color: #333333;">};</span>
Polygon poly1 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates1<span style="color: #333333;">);</span>
Polygon poly2 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates2<span style="color: #333333;">);</span>
Polygon poly3 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>coordinates3<span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly1.touches(poly2) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly1<span style="color: #333333;">.</span><span style="color: #0000cc;">touches</span><span style="color: #333333;">(</span>poly2<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly1.intersects(poly2) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly1<span style="color: #333333;">.</span><span style="color: #0000cc;">intersects</span><span style="color: #333333;">(</span>poly2<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly1.overlaps(poly2) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly1<span style="color: #333333;">.</span><span style="color: #0000cc;">overlaps</span><span style="color: #333333;">(</span>poly2<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"-----------------"</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly1.touches(poly3) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly1<span style="color: #333333;">.</span><span style="color: #0000cc;">touches</span><span style="color: #333333;">(</span>poly3<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly1.intersects(poly3) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly1<span style="color: #333333;">.</span><span style="color: #0000cc;">intersects</span><span style="color: #333333;">(</span>poly3<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly1.overlaps(poly3) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly1<span style="color: #333333;">.</span><span style="color: #0000cc;">overlaps</span><span style="color: #333333;">(</span>poly3<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"-----------------"</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly3.touches(poly1) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly3<span style="color: #333333;">.</span><span style="color: #0000cc;">touches</span><span style="color: #333333;">(</span>poly1<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly3.intersects(poly1) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly3<span style="color: #333333;">.</span><span style="color: #0000cc;">intersects</span><span style="color: #333333;">(</span>poly1<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly3.overlaps(poly1) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly3<span style="color: #333333;">.</span><span style="color: #0000cc;">overlaps</span><span style="color: #333333;">(</span>poly1<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"-----------------"</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly3.touches(poly2) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly3<span style="color: #333333;">.</span><span style="color: #0000cc;">touches</span><span style="color: #333333;">(</span>poly2<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly3.intersects(poly2) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly3<span style="color: #333333;">.</span><span style="color: #0000cc;">intersects</span><span style="color: #333333;">(</span>poly2<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly3.overlaps(poly2) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly3<span style="color: #333333;">.</span><span style="color: #0000cc;">overlaps</span><span style="color: #333333;">(</span>poly2<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"-----------------"</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly2.touches(poly3) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly2<span style="color: #333333;">.</span><span style="color: #0000cc;">touches</span><span style="color: #333333;">(</span>poly3<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly2.intersects(poly3) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly2<span style="color: #333333;">.</span><span style="color: #0000cc;">intersects</span><span style="color: #333333;">(</span>poly3<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"poly2.overlaps(poly3) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>poly2<span style="color: #333333;">.</span><span style="color: #0000cc;">overlaps</span><span style="color: #333333;">(</span>poly3<span style="color: #333333;">)));</span>
</pre></div><p style="text-align: left;"> </p><p style="text-align: left;"></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxTk0aIe1Ga3Rh68qtFf9IxmKeUgPv7wuPL6lm8My41lq7ziWT0oY1KP39IWUR-_NpsSM85vhvm-vzHJGb3uURyO9Cz9cNquzvZCL8TQ4nWT0Wecp1v3vc3Iw2LQ7mniGszp6F2sYnR9w/s458/dokunma_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Dokunma Hesaplama" border="0" data-original-height="458" data-original-width="448" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxTk0aIe1Ga3Rh68qtFf9IxmKeUgPv7wuPL6lm8My41lq7ziWT0oY1KP39IWUR-_NpsSM85vhvm-vzHJGb3uURyO9Cz9cNquzvZCL8TQ4nWT0Wecp1v3vc3Iw2LQ7mniGszp6F2sYnR9w/w391-h400/dokunma_hesaplama.png" title="Dokunma Hesaplama" width="391" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Dokunma Hesaplama</td></tr></tbody></table><br /><p></p><p style="text-align: left;"></p><h3 style="text-align: left;">Equals - Eşit</h3><p style="text-align: left;">JTS kütüphanesinde geometrilerin eşitlik kontrolü 2 farklı şekilde yapılabilmektedir. </p><ul style="text-align: left;"><li>Geometrilerin ifade ettiği manaların eşit olup olmadığını hesaplayan <b>equals(Geometry other) </b>metodu. Bu metod iki geometri nesnesinin koordinat verileri farklı dahi olsa ifade ettikleri şekil aynı ise true dönmektedir. Örneğin, (0, 1), (0, 3) ve (0, 5) noktalarından oluşan çizgi ile (0,5) ve (0, 1) noktalarından oluşan çizgi aynı şekli ifade etmektedir. Ayrıca dikkat çekilmesi gereken bir nokta var. Bu metodun equals şeklinde isimlendirilmesi hoş olmamış. Çünkü Java Object nesnesinin equals(Object obj) metodu ile karıştırılması oldukça olası. Kaldı ki aşağıda örneklerde görüleceği üzere JTS'in equals metodunu çağırmak için parametre (Geometry) nesnesine cast edilmek zorunda. Geometry tipinde olmayan bir parametre ile çağrılırsa Object equals metodu çalıştırılmış oluyor. </li><li>Geometrilerin içerdiği koordinat verilerinin aynı olup olmadığına bakan <b>equalsExact(Geometry other)</b> metodu. Burada geometrilerin ifade ettiği şekil önemli değildir. Tüm koordinat verilerinin aynı olup olmadığına bakılmaktadır. <b>equalsExact(Geometry other) </b>metodu, <b>equals(Geometry other) </b>metodundan daha hızlı çalışmaktadır. <br /><b></b></li></ul><p style="text-align: left;"><a href="https://github.com/mokszr/jts-egitim/blob/master/src/main/java/com/pmobile/jtsegitim/gorsellestirmeler/EsitlikHesaplama.java" target="_blank">EsitlikHesaplama.java </a>sınıfını çalıştırarak sonuçları ekranda görselleştirebilirsiniz.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
Coordinate<span style="color: #333333;">[]</span> coordinates1 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">150</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> coordinates2 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">350</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)};</span>
LineString line1 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span>coordinates1<span style="color: #333333;">);</span>
LineString line2 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span>coordinates2<span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"(line1.equals((Object)line2)) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>line1<span style="color: #333333;">.</span><span style="color: #0000cc;">equals</span><span style="color: #333333;">((</span>Object<span style="color: #333333;">)</span>line2<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"(line1.equals(line2)) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>line1<span style="color: #333333;">.</span><span style="color: #0000cc;">equals</span><span style="color: #333333;">(</span>line2<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"(line1.equals((Geometry)line2)) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>line1<span style="color: #333333;">.</span><span style="color: #0000cc;">equals</span><span style="color: #333333;">((</span>Geometry<span style="color: #333333;">)</span>line2<span style="color: #333333;">)));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"(line1.equalsExact(line2)) "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>line1<span style="color: #333333;">.</span><span style="color: #0000cc;">equalsExact</span><span style="color: #333333;">(</span>line2<span style="color: #333333;">)));</span>
</pre></div><p style="text-align: left;"> </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyF022hX7AXOeptFufgllj1ItLESJQN-Lp5Gth_cjnTXaCopjUmYG0kYA48sDJREIjjlhZGi7PIumEI7orrIuXZua9VzJ_cgzF6m_noFTW8RIrT2Ye1mDWdAkiYqq4MEYFS0vy6FEd5lA/s450/e%25C5%259Fitlik_hesaplama.png" style="margin-left: auto; margin-right: auto;"><img alt="Eşitlik Hesaplama" border="0" data-original-height="367" data-original-width="450" height="326" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyF022hX7AXOeptFufgllj1ItLESJQN-Lp5Gth_cjnTXaCopjUmYG0kYA48sDJREIjjlhZGi7PIumEI7orrIuXZua9VzJ_cgzF6m_noFTW8RIrT2Ye1mDWdAkiYqq4MEYFS0vy6FEd5lA/w400-h326/e%25C5%259Fitlik_hesaplama.png" title="Eşitlik Hesaplama" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Eşitlik Hesaplama<br /></td></tr></tbody></table><br /><p style="text-align: left;"></p><p></p><p>Önceki Bölüm:</p><p class="post-title entry-title" itemprop="name" style="text-align: left;"><a href="https://www.muratoksuzer.com/2021/02/jts-cbs-kutuphanesi-rehberi-1-geometri.html" target="_blank">JTS CBS Kütüphanesi Rehberi 1 - Geometri Modeli</a></p><p class="post-title entry-title" itemprop="name" style="text-align: left;">Sonraki Bölümler</p><p class="post-title entry-title" itemprop="name" style="text-align: left;"><a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-3-geometrik.html " target="_blank">JTS CBS Kütüphanesi Rehberi 3 - Geometrik Alan Hesaplamaları</a></p><p class="post-title entry-title" itemprop="name" style="text-align: left;"><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-4-delaunay-triangulation-voronoi-convex-hull.html " target="_blank">JTS CBS Kütüphanesi Rehberi 4 - Delaunay Üçgenleme, Voronoi Diyagram, Convex Hull </a></p><p class="post-title entry-title" itemprop="name" style="text-align: left;"><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-5-quadtree-nedir-java-ornek.html" target="_blank">JTS CBS Kütüphanesi Rehberi 5 - Quadtree Nedir? Java'da Örnek Kullanım</a></p><p class="post-title entry-title" itemprop="name" style="text-align: left;"><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-6-douglas-peucker-simplifier.html" target="_blank">JTS CBS Kütüphanesi Rehberi 6 - Douglas Peucker Geometri Basitleştirme ve Yoğunlaştırma </a> </p><p class="post-title entry-title" itemprop="name" style="text-align: left;"> </p><p class="post-title entry-title" itemprop="name" style="text-align: left;"> <a href="https://play.google.com/store/books/details?id=4ClVEAAAQBAJ" target="_blank">Download as E-book PDF</a></p><p class="post-title entry-title" itemprop="name" style="text-align: left;"><br /></p><p> </p><p> </p><p> </p><p><br /></p><p><br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-36228562500650997192021-03-01T07:01:00.011-08:002021-12-25T04:05:59.016-08:00JTS CBS Kütüphanesi Rehberi 1 - Geometri Modeli<p>Merhabalar. 2019 yılı başından beri işimde bir <a href="https://tr.wikipedia.org/wiki/Co%C4%9Frafi_bilgi_sistemi" target="_blank">CBS (coğrafi bilgi sistemi)</a> ürünü üzerinde çalışıyorum. Java dünyasında harita üzerinde geliştirilen pek çok yetenekte <a href="https://github.com/locationtech/jts" target="_blank">JTS (JTS Topology Suite)</a> kütüphanesinin yeteneklerinden faydalanılmakta. Hatta sadece <a href="https://en.wikipedia.org/wiki/Geographic_information_system" target="_blank">GIS</a> yazılımlarında değil, nesnelerin çarpışıp çarpışmadığını kontrol etmek amacıyla oyunlarda bile kullanılabilmektedir. Fakat internette arattığımda bu kütüphane ile alakalı Türkçe kaynak azlığı dikkatimi çekti. İhtiyacı olanlara yardımcı olmasını umarak dilim döndüğünce bu kütüphaneden bahsedeceğim yazı dizisine başlıyorum. </p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL42cQmXmSWMOjQEZRNzby48bpE1Kpk-99x5PDMrNCfT_uN9U74rTKIVIbpcI86Q97x1bOO867wT8Cqj8oavKMaCvhiDihqse6qb-hBZyuGnVBw59x4JqClh6S3Ehy8bXKSdRVMqEQN18/s192/jts_logo.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="109" data-original-width="192" height="182" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL42cQmXmSWMOjQEZRNzby48bpE1Kpk-99x5PDMrNCfT_uN9U74rTKIVIbpcI86Q97x1bOO867wT8Cqj8oavKMaCvhiDihqse6qb-hBZyuGnVBw59x4JqClh6S3Ehy8bXKSdRVMqEQN18/w320-h182/jts_logo.png" width="320" /></a></div><br /> <p></p><h3 style="text-align: left;">Kurulum <br /></h3><p>Öncelikle Maven bağımlılığına <a href="https://mvnrepository.com/artifact/org.locationtech.jts/jts-core" target="_blank">şuradan</a> ulaşabilirsiniz. Maven repolarında jts diye arattığınızda kafa karıştırıcı bir durumla karşılaşıyorsunuz. Farklı paket adına sahip sürümler mevcut. Kütüphane <b>1.14</b> sürümüne kadar <b>com.vividsolutions.jts</b> paket adına sahip idi. Geliştiren ekip değiştiğinden dolayı <b>1.15</b> sürümünden itibaren <b>org.locationtech.jts</b> paket adına sahip olarak yayınlanıyor. Ben bu yazıyı yazarken en güncel sürüm <b>1.18.0</b> idi.</p><h3 style="text-align: left;">Geometri Modeli<br /></h3><p>JTS kütüphanesi, <a href="https://www.ogc.org/standards/sfa" target="_blank">OGC'nin (Open Geospatial Consortium)</a> standart olarak tanımladığı tüm geometrik tipleri desteklemektedir. Bunlar:</p><ul style="text-align: left;"><li><b>Point </b>ve <b>MultiPoint </b>(nokta ve çoklu nokta)<br /></li><li><b>LineString </b>ve <b>MultiLineString </b>(çizgi ve çoklu çizgi)<br /></li><li><b>Polygon </b>ve <b>MultiPolygon </b>(poligon ve çoklu poligon)</li><li>İçinde karışık türlerin bulunabileceği <b>GeometryCollection </b><br /></li></ul><h3 style="text-align: left;">Coordinate Sınıfı<br /></h3><p>Geometri modeli sınıflarını oluşturan konum bilgilerini tutan sınıf <b>Coordinate </b>sınıfıdır.<b> X, Y </b>ve <b>Z</b> koordinat verilerini tutabilmektedir. CBS yazılımlarında X boylam, Y enlem, Z de yükseklik verisini tutacak şekilde kullanılmaktadır. Yükseklik verisini tutsa da, JTS kütüphanesinin 3D (3 boyutlu) geometrik hesaplama kabiliyeti bulunmuyor. Geometrik hesaplamalarında sadece X ve Y değerlerini dikkate alıyor. Oyunlarda bu X, Y ve Z değerleri piksel ve derinlik tutmak için de kullanılabilmektedir.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"> Coordinate coordinate <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">10</span><span style="color: #333333;">);</span>
</pre></div><h3 style="text-align: left;"> </h3><h3 style="text-align: left;">GeometryFactory <br /></h3><p>Geometri modeli kapsamındaki nesneleri üretmek için GeometryFactory sınıfı kullanılmaktadır.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">GeometryFactory geometryFactory <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> GeometryFactory<span style="color: #333333;">();</span>
</pre></div><h3 style="text-align: left;"> </h3><h3 style="text-align: left;">Point</h3><p>Bir adet Coordinate nesnesi alarak oluşturulur. </p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"> Point point <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPoint</span><span style="color: #333333;">(</span>coordinate<span style="color: #333333;">);</span>
</pre></div><h3 style="text-align: left;"> </h3><h3 style="text-align: left;">MultiPoint</h3><p style="text-align: left;">Birden fazla konum verisi alarak oluşturulur.<br /></p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">Coordinate<span style="color: #333333;">[]</span> coordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">39</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">33</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">46</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">23</span><span style="color: #333333;">)};</span>
MultiPoint multiPoint <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createMultiPointFromCoords</span><span style="color: #333333;">(</span>coordinates<span style="color: #333333;">);</span>
</pre></div><h3 style="text-align: left;"> </h3><h3 style="text-align: left;">LineString<br /></h3><p>Çizgi nesneleri LineString kullanarak temsil edilmektedir. Birden fazla konum alarak oluşturulur. simple, non-simple, closed, not-closed türleri vardır. Kendisi ile kesişmeyen çizgilere simple, kesişenlere ise non-simple denilmektedir. Başlangıç ve bitiş koordinatları aynı olan çizgilere closed denilmektedir.</p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijq7H55tVdlXPRCt41SvXefLGDdC7vuYEGUgLYC-Vzh6VYmNkUO4I5-O-PKPstGvZiUbo2oArIQz9kMvkDy2JaesKXXZI1kQaIfVFnPGaD8TWJ0l3o-Y9iYwp62gVB9LR5PGINH4gdii4/s972/simple_lineString.png" style="margin-left: auto; margin-right: auto;"><img alt="Line String" border="0" data-original-height="606" data-original-width="972" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijq7H55tVdlXPRCt41SvXefLGDdC7vuYEGUgLYC-Vzh6VYmNkUO4I5-O-PKPstGvZiUbo2oArIQz9kMvkDy2JaesKXXZI1kQaIfVFnPGaD8TWJ0l3o-Y9iYwp62gVB9LR5PGINH4gdii4/w400-h249/simple_lineString.png" title="line String" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">line string<br /></td></tr></tbody></table><br /><p></p><h3 style="text-align: left;">LineRing<br /></h3><p>LineString sınıfının bir alt sınıfı olan LineRing closed ve simple LineString nesneleri oluşturmak için kullanılmaktadır. Closed veya simple olmayan koordinat dizisiyle LineRing oluşturmaya çalışılırsa hata alınacaktır.</p><p><b>java.lang.IllegalArgumentException: Points of LinearRing do not form a closed linestring</b></p><h3 style="text-align: left;">MultiLineString<br /></h3><p>Birden fazla LineString nesnesi alarak oluşturulur.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">Coordinate<span style="color: #333333;">[]</span> coordinates1 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">39</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">33</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">46</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">23</span><span style="color: #333333;">)};</span>
LineString lineString1 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span>coordinates1<span style="color: #333333;">);</span>
Coordinate<span style="color: #333333;">[]</span> coordinates2 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">26</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">38</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">30</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">37</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #6600ee; font-weight: bold;">40.5</span><span style="color: #333333;">,</span> <span style="color: #6600ee; font-weight: bold;">39.785</span><span style="color: #333333;">)};</span>
LineString lineString2 <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLineString</span><span style="color: #333333;">(</span>coordinates2<span style="color: #333333;">);</span>
LineString<span style="color: #333333;">[]</span> lineStrings <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> LineString<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span>lineString1<span style="color: #333333;">,</span> lineString2<span style="color: #333333;">};</span>
MultiLineString multiLineString <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createMultiLineString</span><span style="color: #333333;">(</span>lineStrings<span style="color: #333333;">);</span>
</pre></div><h3 style="text-align: left;"> </h3><h3 style="text-align: left;">Polygon<br /></h3><p>Bir adet LineRing veya LineRing oluşturulabilecek koordinat dizisi alarak oluşturulur. Yani başlangıç ve bitiş koordinatları aynı olmayan veriden oluşturulmaya çalışılırsa hata atacaktır.</p><p><b> java.lang.IllegalArgumentException: Points of LinearRing do not form a closed linestring</b></p><p>Örnek bir poligon üretimi şu şekildedir.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">Coordinate<span style="color: #333333;">[]</span> polygonCoordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">39</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">33</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">46</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">23</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">40</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">27</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">39</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">33</span><span style="color: #333333;">)};</span>
Polygon polygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>polygonCoordinates<span style="color: #333333;">);</span>
</pre></div><p> </p><p>Ayrıca içerisinde boşluk olan poligonlar da üretilebilmektedir. </p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">Coordinate<span style="color: #333333;">[]</span> polygonCoordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">39</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">33</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">46</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">23</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">40</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">27</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">39</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">33</span><span style="color: #333333;">)};</span>
Coordinate<span style="color: #333333;">[]</span> holeCoordinates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">40</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">34</span><span style="color: #333333;">),</span>
<span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">Coordinate</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">45</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">24</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">41</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">26</span><span style="color: #333333;">),</span> <span style="color: #008800; font-weight: bold;">new</span> Coordinate<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">40</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">34</span><span style="color: #333333;">)};</span>
LinearRing hole <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLinearRing</span><span style="color: #333333;">(</span>holeCoordinates<span style="color: #333333;">);</span>
LinearRing<span style="color: #333333;">[]</span> holes <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> LinearRing<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span> hole <span style="color: #333333;">};</span>
LinearRing shell <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createLinearRing</span><span style="color: #333333;">(</span>polygonCoordinates<span style="color: #333333;">);</span>
Polygon polygonWithHole <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createPolygon</span><span style="color: #333333;">(</span>shell<span style="color: #333333;">,</span> holes<span style="color: #333333;">);</span>
</pre></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3q_8nsHOALaGoqZlO2K0C3W6JttS3eZDHlPvCfihGNfLiIbHJqa4PEBCpCoKE1ca8kfh6fqjm5_aCeFhUCWlabbiUCIZTz-X9U61_bZzD-IrSU3SNa5183A0GW02qLSHQOL_xLW4GE_s/s863/polygon.png" style="margin-left: auto; margin-right: auto;"><img alt="Polygon" border="0" data-original-height="476" data-original-width="863" height="221" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3q_8nsHOALaGoqZlO2K0C3W6JttS3eZDHlPvCfihGNfLiIbHJqa4PEBCpCoKE1ca8kfh6fqjm5_aCeFhUCWlabbiUCIZTz-X9U61_bZzD-IrSU3SNa5183A0GW02qLSHQOL_xLW4GE_s/w400-h221/polygon.png" title="Polygon" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Polygon</td></tr></tbody></table><p> </p><h3 style="text-align: left;">MultiPolygon <br /></h3><p>Birden fazla poligon nesnesi alarak oluşturulur.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">Polygon<span style="color: #333333;">[]</span> polygons <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Polygon<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span>polygon<span style="color: #333333;">,</span> polygonWithHole<span style="color: #333333;">};</span>
MultiPolygon multiPolygon <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createMultiPolygon</span><span style="color: #333333;">(</span>polygons<span style="color: #333333;">);</span>
</pre></div><h3 style="text-align: left;"> </h3><h3 style="text-align: left;">GeometryCollection</h3><p>Diğer tüm geometri tipleri içerebilecek bir koleksiyon türü görevi görmektedir. </p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">Geometry<span style="color: #333333;">[]</span> geometries <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Geometry<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span>point<span style="color: #333333;">,</span> multiLineString<span style="color: #333333;">,</span> polygon<span style="color: #333333;">,</span> multiPolygon<span style="color: #333333;">};</span>
GeometryCollection geometryCollection <span style="color: #333333;">=</span> geometryFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">createGeometryCollection</span><span style="color: #333333;">(</span>geometries<span style="color: #333333;">);</span>
</pre></div><p> Sonraki Bölümler</p><p><a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-2-geometrik.html" target="_blank">JTS CBS Kütüphanesi Rehberi 2 - Geometrik İlişki Hesaplamaları </a></p><p><a href="https://www.muratoksuzer.com/2021/03/jts-cbs-kutuphanesi-rehberi-3-geometrik.html " target="_blank">JTS CBS Kütüphanesi Rehberi 3 - Geometrik Alan Hesaplamaları </a></p><p><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-4-delaunay-triangulation-voronoi-convex-hull.html " target="_blank">JTS CBS Kütüphanesi Rehberi 4 - Delaunay Üçgenleme, Voronoi Diyagram, Convex Hull </a></p><p><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-5-quadtree-nedir-java-ornek.html" target="_blank">JTS CBS Kütüphanesi Rehberi 5 - Quadtree Nedir? Java'da Örnek Kullanım</a></p><p><a href="https://www.muratoksuzer.com/2021/04/jts-cbs-kutuphanesi-rehberi-6-douglas-peucker-simplifier.html" target="_blank">JTS CBS Kütüphanesi Rehberi 6 - Douglas Peucker Geometri Basitleştirme ve Yoğunlaştırma </a> </p><p><a href="https://play.google.com/store/books/details?id=4ClVEAAAQBAJ" target="_blank">Download as E-book PDF</a></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-88041696371762550712021-02-15T09:26:00.002-08:002021-04-21T11:34:21.045-07:00Java'da BÖL - PARÇALA - YÖNET (Fork / Join Pool Kullanımı)<p>Merhabalar. Yoğun işlem yüklü hesaplamalarımızı paralel olarak çalıştırarak süreden kazanmak istemez miyiz? Bu yazımda Java'da işlem yükünü işlemcide birden fazla çekirdeğe yayarak paralel çalıştırma altyapısı olan Fork / Join Pool kullanımından bahsedeceğim. </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_4Nu7Gg8F5d2K3SeNa-Mm0pdbI0QdFk5qNOlfdbn_XEHsCcdHoXMO1rnBzsDBJs057tsJ2Ugto13klHer6qp2_4mYSJHGED_rTVRLPHJYUsECnxDbhXEN-NqLFBNOuFoI-KNW16acYheg/s600/forkjoinpool_in_java.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Java'da ForkJoinPool kullanımı" border="0" data-original-height="500" data-original-width="600" height="334" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_4Nu7Gg8F5d2K3SeNa-Mm0pdbI0QdFk5qNOlfdbn_XEHsCcdHoXMO1rnBzsDBJs057tsJ2Ugto13klHer6qp2_4mYSJHGED_rTVRLPHJYUsECnxDbhXEN-NqLFBNOuFoI-KNW16acYheg/w400-h334/forkjoinpool_in_java.png" title="Java'da ForkJoinPool kullanımı" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Java'da ForkJoinPool kullanımı</td></tr></tbody></table><p> </p><p>Fork / Join altyapısı, tanımlanan bir işi asenkron olarak çalıştırılabilecek daha küçük alt işlere böler (<b>Fork</b>). Yeterince böldüğüne kanaat getirdiğinde alt işleri asenkron olarak çalıştırır ve sonuçlarını birleştire birleştire tanımlı işi tamamlar. Eğer alt işler void dönüyor ve birleştirilecek birşey yok ise, sadece tüm alt işlemlerin bitmesini bekler (<b>Join</b>). Her alt işlem için yeni thread oluşturmaz. Tanımlanan <b>ForkJoinPool </b>nesnesi, kendisine bildirilen çekirdek sayısını optimum kullanacak şekilde alt işleri bir sıraya koyar ve threadlere dağıtır. </p><p> </p><p>Çok basit bir senkron for döngüsünü Fork / Join yapısını kullanır hale getirerek kazandığımız süreyi hep beraber görelim.</p><p>Öncelikle senkron çalışan kod aşağıdaki gibidir. For döngüsü içinde pahalı bir işlem olduğunu simüle edebilmek için bir miktar hesaplama kodu ekledim. </p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">main</span><span style="color: #333333;">(</span>String<span style="color: #333333;">[]</span> args<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">long</span> baslangic <span style="color: #333333;">=</span> System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">();</span>
Map<span style="color: #333333;"><</span>Integer<span style="color: #333333;">,</span> Double<span style="color: #333333;">></span> sonucMap <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ConcurrentHashMap<span style="color: #333333;"><>();</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> <span style="color: #0000dd; font-weight: bold;">1000000</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">double</span> kare <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">sqrt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> tan <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">tan</span><span style="color: #333333;">(</span>kare<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> cos <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">cos</span><span style="color: #333333;">(</span>tan<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> radians <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">toRadians</span><span style="color: #333333;">(</span>cos<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> degrees <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">toDegrees</span><span style="color: #333333;">(</span>radians<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> exp <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">exp</span><span style="color: #333333;">(</span>degrees<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> log10 <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">log10</span><span style="color: #333333;">(</span>exp<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> atan2 <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">atan2</span><span style="color: #333333;">(</span>log10<span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> sqrt <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">sqrt</span><span style="color: #333333;">(</span>atan2<span style="color: #333333;">*</span>atan2 <span style="color: #333333;">+</span> log10 <span style="color: #333333;">*</span> log10<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> square <span style="color: #333333;">=</span> sqrt <span style="color: #333333;">*</span> sqrt<span style="color: #333333;">;</span>
sonucMap<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>i<span style="color: #333333;">,</span> square<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"süre "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">()</span> <span style="color: #333333;">-</span> baslangic<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" ms"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
</pre></div><p>Bu kodu makinamda birden fazla kez çalıştırdığımda süreler yaklaşık 470 - 500 ms arası oluyor.</p><p>Şimdi de Fork / Join yapısını kullanan sınıfı görelim.</p><div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-width: .1em .1em .1em .8em; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">BolParcalaYonet</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Hesaplama</span> <span style="color: #008800; font-weight: bold;">extends</span> RecursiveAction <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> baslangic<span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> bitis<span style="color: #333333;">;</span>
Map<span style="color: #333333;"><</span>Integer<span style="color: #333333;">,</span> Double<span style="color: #333333;">></span> sonucMap<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> <span style="color: #333399; font-weight: bold;">int</span> THRESHOLD <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">100000</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Hesaplama</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> baslangic<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> bitis<span style="color: #333333;">,</span> Map<span style="color: #333333;"><</span>Integer<span style="color: #333333;">,</span> Double<span style="color: #333333;">></span> sonucMap<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">baslangic</span> <span style="color: #333333;">=</span> baslangic<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">bitis</span> <span style="color: #333333;">=</span> bitis<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">sonucMap</span> <span style="color: #333333;">=</span> sonucMap<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">protected</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">compute</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>bitis <span style="color: #333333;">-</span> baslangic <span style="color: #333333;">></span> THRESHOLD<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
ForkJoinTask<span style="color: #333333;">.</span><span style="color: #0000cc;">invokeAll</span><span style="color: #333333;">(</span>altIslereBol<span style="color: #333333;">());</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
hesapla<span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">hesapla</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">for</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> baslangic<span style="color: #333333;">;</span> i <span style="color: #333333;"><=</span> bitis<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">double</span> kare <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">sqrt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> tan <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">tan</span><span style="color: #333333;">(</span>kare<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> cos <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">cos</span><span style="color: #333333;">(</span>tan<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> radians <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">toRadians</span><span style="color: #333333;">(</span>cos<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> degrees <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">toDegrees</span><span style="color: #333333;">(</span>radians<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> exp <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">exp</span><span style="color: #333333;">(</span>degrees<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> log10 <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">log10</span><span style="color: #333333;">(</span>exp<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> atan2 <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">atan2</span><span style="color: #333333;">(</span>log10<span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> sqrt <span style="color: #333333;">=</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">sqrt</span><span style="color: #333333;">(</span>atan2<span style="color: #333333;">*</span>atan2 <span style="color: #333333;">+</span> log10 <span style="color: #333333;">*</span> log10<span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">double</span> square <span style="color: #333333;">=</span> sqrt <span style="color: #333333;">*</span> sqrt<span style="color: #333333;">;</span>
sonucMap<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>i<span style="color: #333333;">,</span> square<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> List<span style="color: #333333;"><</span>Hesaplama<span style="color: #333333;">></span> <span style="color: #0066bb; font-weight: bold;">altIslereBol</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
List<span style="color: #333333;"><</span>Hesaplama<span style="color: #333333;">></span> subtasks <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #333399; font-weight: bold;">int</span> orta <span style="color: #333333;">=</span> baslangic <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>bitis <span style="color: #333333;">-</span> baslangic<span style="color: #333333;">)</span> <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">;</span>
<span style="color: #888888;">// System.out.println("bas orta bitis " + baslangic + " " + orta + " " + bitis);</span>
subtasks<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Hesaplama<span style="color: #333333;">(</span>baslangic<span style="color: #333333;">,</span> orta<span style="color: #333333;">,</span>sonucMap<span style="color: #333333;">));</span>
subtasks<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Hesaplama<span style="color: #333333;">(</span>orta <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">,</span> bitis<span style="color: #333333;">,</span> sonucMap<span style="color: #333333;">));</span>
<span style="color: #008800; font-weight: bold;">return</span> subtasks<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">main</span><span style="color: #333333;">(</span>String<span style="color: #333333;">[]</span> args<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
ForkJoinPool commonPool <span style="color: #333333;">=</span> ForkJoinPool<span style="color: #333333;">.</span><span style="color: #0000cc;">commonPool</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">long</span> baslangic <span style="color: #333333;">=</span> System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">();</span>
Map<span style="color: #333333;"><</span>Integer<span style="color: #333333;">,</span> Double<span style="color: #333333;">></span> sonucMap <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ConcurrentHashMap<span style="color: #333333;"><>();</span>
Hesaplama hesaplama <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Hesaplama<span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">1000000</span><span style="color: #333333;">,</span> sonucMap<span style="color: #333333;">);</span>
commonPool<span style="color: #333333;">.</span><span style="color: #0000cc;">invoke</span><span style="color: #333333;">(</span>hesaplama<span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"süre "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">currentTimeMillis</span><span style="color: #333333;">()</span> <span style="color: #333333;">-</span> baslangic<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" ms"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><p><br /></p><p>Aynı hesaplamayı bu şekilde birden fazla kez çalıştırdığımda süreler yaklaşık 160 - 180 ms arasında oluyor. Çok büyük bir performans kazanımı olduğu görülüyor.</p><p>Burada belirleyeceğimiz eşik (<b>treshold</b>) değerine dikkat etmmemiz gerekiyor. Eğer üzerinde çalıştığımız işlemcinin çekirdek sayısına oranla çok fazla alt işlere bölme ile sonuçlanacak bir eşik değer belirlenirse performans kazanmayı beklerken tam tersi performans kaybıyla da karşılaşabiliriz.</p><p>altIslereBol() metodunda yorumda bıraktığımız println satırını açarsak, hangi başlangıç bitiş alt işlerine ayırdığını konsolda daha net şekilde görüp anlayabiliriz.</p><p>></p><p><span style="font-family: trebuchet;">bas orta bitis 0 500000 1000000<br />bas orta bitis 0 250000 500000<br />bas orta bitis 500001 750000 1000000<br />bas orta bitis 0 125000 250000<br />bas orta bitis 500001 625000 750000<br />bas orta bitis 750001 875000 1000000<br />bas orta bitis 0 62500 125000<br />bas orta bitis 625001 687500 750000<br />bas orta bitis 500001 562500 625000<br />bas orta bitis 750001 812500 875000<br />bas orta bitis 875001 937500 1000000<br />bas orta bitis 250001 375000 500000<br />bas orta bitis 250001 312500 375000<br />bas orta bitis 125001 187500 250000<br />bas orta bitis 375001 437500 500000<br />süre 179 ms</span><br /></p><p> <br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-38802810651867439212021-02-09T02:35:00.001-08:002021-02-09T04:46:55.092-08:00Java Sürprizleri<p>Merhabalar. Java kodlarken hiç ummadığınız hatalarla saatler harcadığınız sizin de olmuştur. Onca tecrübenize rağmen Java dilinin geliştiricilerinin size hazırladığı sürprizlerle karşılaşırsınız ara sıra. Bu yazımda karşılaştığım sıradışı Java özelliklerinden bahsedeceğim.</p><p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgovVlidJsrurNlRSAGOufbG2x95kGtZ-od4bMTqa5J2iucWPNtQo1kawQ1ga2ZyyUPbCOCd43JezPnwmYzWdMl0j253nnMkhCUAwPFVE_q5ZUvXCu8M3oT5HZOYiL-zn5hKPJtNQy638o/s508/surprisedcat.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="508" data-original-width="508" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgovVlidJsrurNlRSAGOufbG2x95kGtZ-od4bMTqa5J2iucWPNtQo1kawQ1ga2ZyyUPbCOCd43JezPnwmYzWdMl0j253nnMkhCUAwPFVE_q5ZUvXCu8M3oT5HZOYiL-zn5hKPJtNQy638o/s320/surprisedcat.jpg" /></a></div><br /><p></p><h2 style="text-align: left;">File exist() Metodu Aynı Dosya İçin Linux ve Windows'da Farklı Sonuç Dönebilir <br /></h2><p>Elimizde ADANA.JPG isimli bir dosya olsun. Kodumuzun bir yerinde </p><span> </span><span> </span>File memleket = new File("adana.jpg"); <br /><br /> System.out.println("memleket exist() " + memleket.exists()); <br /><p>satırları bulunsun. Sizce konsola ne yazacaktır? Linux oramında iseniz false Windows ortamında iseniz true yazacaktır. exist() metodu dosyanın olup olmadığının cevabını işletim sistemine sorarak dönmektedir. Windows ise dosya adlarının harflerinin büyük ya da küçük olmasıyla ilgilenmeden cevap dönerken Linux sistemler kesinlikle aynı büyük küçük harflere sahip dosya olup olmadığına bakmaktadır.</p><h2 style="text-align: left;"> PriorityQueue İteratörü Sıralı Dönmek Zorunda Değil<br /></h2><p> PriorityQueue<SinavSonucu> sinavSonuclari = new PriorityQueue<>(); </p><p>şeklinde bir PriorityQueue nesnemiz olsun. PriorityQueue nesnesi genelde hep içindeki elemanların en önceliklisini alıp aynı zamanda queue içinden silinmesi ile sonuçlanan poll() metodu ile kullanılır. Queue içindeki nesneleri silmeden dolaşmak istediğimizde de diğer Collection nesnelerinde olduğu gibi iteratorünü kullanarak dolaşırız.</p><p><span></span><span> </span><span> </span>for(SinavSonucu sonuc : sinavSonuclari){</p><p><span> </span><span> </span><span> </span>// .... <br /></p><p><span> </span><span> </span>} </p><p>Fakat burada dikkat etmemiz gereken bir nokta var. İçgüdüsel olarak bu for içinde de elemanları öncelik sırasına göre dolaşacağımızı varsayabiliriz. Fakat bu doğru değil. PriorityQueue nesnelerinin iterator() metodu içindeki nesneleri poll() metodunda olduğu gibi öncelik sırasına göre vermeyi garanti etmiyor.</p><p> </p><h2 style="text-align: left;">Double.MIN_VALUE Sıfırdan Büyüktür</h2><p>Java'da nümerik değerlerin MAX ve MİN değerlerine ulaşmamız gereken durumlar olabilir. Mesela, Integer.MAX_VALUE, Integer.MIN_VALUE, veya konumuz olan Double.MIN_VALUE. Sizce aşağıdaki kodun konsol çıktısı ne olacaktır?</p><p></p><p><span> </span><span> </span>System.out.println(Double.MIN_VALUE); </p><p><span> </span><span> </span>if(Double.MIN_VALUE > 0) {<br /> System.out.println("Hakkaten sıfırdan byükmüş");<br /> }<br /> </p><p><span> </span><span> </span>System.out.println(Integer.MIN_VALUE);<br /> </p><p><span> </span><span> </span>if(Integer.MIN_VALUE > 0) {<br /> <span> </span><span> </span> System.out.println("integer min value sıfırdan büyük");<span> </span></p><p><span> </span><span> </span>}<br /></p><p>> 4.9E-324<br />Hakkaten sıfırdan byükmüş<br />-2147483648<br /></p><p>Integer.MIN_VALUE negatif en küçük integer değeri verirken Double.MIN_VALUE ise negatif en küçük double değeri yerine sıfırdan büyük en küçük Double değerini veriyor. Dikkat etmek lazım.</p><p><br /></p><p><br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-42906456792720955842020-09-11T23:27:00.002-07:002020-09-11T23:27:28.780-07:00 Koronavirüs Etrafında Design Patternlar<p> Merhabalar. Tasarım desenleri iş mülakatlarında sıkça sorulan sorulardandır. Akılda kalıcı olması açısından gerçek hayattan örneklendirmekte fayda var. Covid-19 salgınıyla uğraştığımız şu günlerde güncele uygun şu örnekler verilebilir.</p><p></p><p>
<span class="break-words"><span dir="ltr">Koronavirüs etrafında design patternlar:</span></span></p><p><span class="break-words"><span dir="ltr"> </span></span><span class="break-words"><span dir="ltr">Proxy Pattern: : Kendisini olduğundan farklı olarak hücre için gerekli gibi gösterip hücre içine kabul edilme yeteneği.<br /><br />Factory Pattern: : Hücre içine girince hücreyi kendisini çoğaltacak bir fabrika haline getirmesi. <br /><br />Adapter Pattern: : Arayüzünü hücreye uyumlu tutarak hücre proteinlerine tutunabilmesi.<br /><br />State Pattern: : Hücre dışındayken "Hücre Aranıyor" state'indeyken hücre içine girince "Çoğaltılıyor" state'ine geçmesi. <br /><br />Prototype
Pattern: : Aşılar içinde bağışıklık sistemine virüsün ölü bir kopyası
verilerek olası karşılaşmalarda bağışıklık sisteminin virüsü tanımasının
sağlanması.<br /><br />Strategy Pattern: İnsanoğlunun koronavirüs öncesi
gündelik yaşam stratejisini yeni normal kurallarına göre değiştirmesi,
maske mesafe temizlik!</span></span></p><p><span class="break-words"><span dir="ltr"> </span></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeW8xTwErb5ifDja40_I9hQ4_tE98hKZwt5TvBiR7J0oEM_JhGWKLH_WTlHojQBDc5MHKN_CNEnm8uDR3nruIITHtJbUIEyRzDvIcB_3rYEs6sNIs2RoOKJ6_RPTbEnVepaZnRPK3X5IA/s410/Coronavirus_410x270px.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="270" data-original-width="410" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeW8xTwErb5ifDja40_I9hQ4_tE98hKZwt5TvBiR7J0oEM_JhGWKLH_WTlHojQBDc5MHKN_CNEnm8uDR3nruIITHtJbUIEyRzDvIcB_3rYEs6sNIs2RoOKJ6_RPTbEnVepaZnRPK3X5IA/s320/Coronavirus_410x270px.jpg" width="320" /></a></div><br /><p></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-47479935093913830302020-07-28T11:44:00.010-07:002021-07-05T14:45:36.942-07:00Çalışmak ve İş İle Alakalı Atasözleri Deyimler<p>Bir konuya bir toplumun nasıl baktığını anlamak için o konuda üretilmiş kültürel varlıklara bakmak gerekir. Kültürümüzde çalışmak ve iş konusu nasıl ele alınmış biraz anlamak için şu özlü sözlere, atasözlerine deyimlere bakabiliriz:</p><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxXSyxG1ek0MUIJO2iJ8l_awdqDXWGfzMJmcHC8pHvn2SF1honr-V7M_vnfbGosx-sAVpFgWy0ZMktK9DpfHZSIlw7wCjv_bkV3g21jec83yncx34DouRFIPie1PLUBlAyNUQj6EMQz4A/s1536/kalin_kitap.jpg" style="margin-left: auto; margin-right: auto;"><img alt="Çalışmak İş Atasözleri Deyimler Özlü Sözler" border="0" data-original-height="767" data-original-width="1536" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxXSyxG1ek0MUIJO2iJ8l_awdqDXWGfzMJmcHC8pHvn2SF1honr-V7M_vnfbGosx-sAVpFgWy0ZMktK9DpfHZSIlw7wCjv_bkV3g21jec83yncx34DouRFIPie1PLUBlAyNUQj6EMQz4A/w400-h200/kalin_kitap.jpg" title="Çalışmak İş Atasözleri Deyimler Özlü Sözler" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Çalışmak İş Atasözleri Deyimler Özlü Sözler</td></tr></tbody></table><br /><b>Boş gezmekten bedava çalışmak yeğdir.</b><br />Atasözü<br />Çalışmak insanı tembellikten kurtarır.<br /> <p></p><p><b>Irgat gibi çalışmak</b><br />Deyim<br />Çok ağır bir işte çalışmak.</p><p><br /><b>İt gibi çalışmak</b><br />Deyim<br />Çok çalışmak, yorulmak.</p><p><br /><b>Kafası işlemek (çalışmak)</b><br />Deyim<br />Aklı, zekâsı yerinde olmak, bir konu üzerinde iyi düşünebilir olmak: 'Hasan'ın kafası şimdi üç cepheli işliyordu.' -O. C. Kaygılı.</p><p><br /><b>Kendi hesabına çalışmak</b><br />Deyim<br />Uğraştığı işi sadece kendisi için yapmak: 'Böyle bir amatörlük devresi geçirdikten sonra biraz da kendi hesabına çalışmayı düşündü.' -R. N. Güntekin.</p><p><br /><b>Rölantide durmak (çalışmak)</b><br />Deyim<br />Motorlu taşıtlarda, motor boşta çalışmak.</p><p><b>Serbest çalışmak</b><br />Deyim<br />Bir işverene bağlı olmadan kendi adına kazanç sağlamak.</p><p><b>Yazın çalışan, kışın gülüşür.</b><br />Atasözü<br />Yazın çalışan kışın rahat eder.</p><p><b>Acele işe şeytan karışır</b><br />Atasözü<br />Düşünüp taşınmadan ivedi olarak yapılan işten iyi sonuç alınamaz.<br /><br /><b>Acele işin sonu pişmanlık</b><br />Atasözü<br />Acele ederek yaptığımız işten istediğimiz sonucu alamayabiliriz.<br /></p><p><b>Adamın iyisi işbaşında (alışverişte) belli olur</b><br />Atasözü<br />Bir kişinin iyi ve becerikli olduğu yaptığı işlerden anlaşılır.</p><p><b>Akıl kişiye (adama) sermayedir</b><br />Atasözü<br />Bir kimsenin giriştiği işlerde en büyük yardımcısı aklıdır.</p><p></p><p><b>Akıllar gelin olmuş, herkes kendininkini beğenmiş</b><br />Atasözü<br />İnsan kendi aklını, düşüncesini başkasınınkinden üstün görür.<br /></p><p><b>Bakmakla usta olunsa (öğrense), köpekler (kediler) kasap olurdu (kasaplığı öğrenirdi)</b><br />Atasözü<br />Yapılmadan yalnızca nasıl yapıldığı görülerek hiçbir şey öğrenilemez.<br /><br /><br /><b>Kabiliyetli çırak ustayı geçer</b><br />Atasözü<br />Yetenekli çırak, ustasından daha usta olur.</p><p><br /><b>Sanatı ustadan görmeyen (öğrenmeyen) öğrenmez</b><br />Atasözü<br />Kişi tek başına ne kadar çalışırsa çalışsın işin inceliklerini bir bilenden öğrenirse o işi daha çabuk ve kolay yapabilir.<br /><br /><b>Usta maymun kamçı istemez</b><br />Atasözü<br />İşini iyi bilen kişiye zorlama gerekmez.</p><p><br /><b>Usta yanında perende atılmaz</b><br />Atasözü<br />Bir konuda tam beceri kazanmamış olan kişi, o işin uzmanıyla kalkışacağı üstünlük yarışında yenilgiye uğrar.<br /><br /><b>Ustanın çekici bin altın</b><br />Atasözü<br />Alanında uzman olan bir kişi, bir sorunu kolayca çözümleyebilme becerisi gösteriyorsa bu, aynı işe yıllarca verilmiş emeklerin karşılığı olarak değerlendirilmelidir.<br /><br /><b>Ağanın alnı terlemezse ırgadın burnu kanamaz</b><br />Atasözü<br />İşveren işçisi ile birlikte çalışmazsa işçi işe var gücüyle sarılmaz.<br /><br /><b>Ağanın gözü ata tımardır</b><br />Atasözü<br />İş sahipleri denetimlerini sürekli yaparlarsa işler yolunda gider.<br /><br /><b>Ağanın gözü, yiğidin sözü</b><br />Atasözü<br />Çalışanlarını gereği gibi yöneten ve çalıştıran kişi iyi bir yöneticidir, sözünün eri olan kimse de yiğittir.<br /><br /><b>(bir işte) saç sakal ağartmak</b><br />Deyim<br />O işte uzun zaman çalışmış, emek vermiş olmak.<br /><br /><b>Sanat altın bileziktir</b><br />Atasözü<br />Kişinin elindeki sanat, değeri hiç eksilmeyen bir servettir.<br /><br /><b>Sanatı ustadan görmeyen (öğrenmeyen) öğrenmez</b><br />Atasözü<br />Kişi tek başına ne kadar çalışırsa çalışsın işin inceliklerini bir bilenden öğrenirse o işi daha çabuk ve kolay yapabilir.</p><p><br /><b>Sanatına hor bakan (sanatını hor gören) boğazına torba takar</b><br />Atasözü<br />İşini küçümseyen kişi istediği gibi para kazanamaz ve sonunda dilenci olur.</p><p><br /><b>Sanatını hor gören boğazına torba takar</b><br />Atasözü<br />İşini küçümseyen kişi istediği gibi para kazanamaz ve sonunda dilenci olur.<br /><br /><br /><b>Akşamın işini sabaha (yarına) bırakma</b><br />Atasözü<br />Bugün yapılması gereken bir işi ertesi güne bırakma.<br /><br /><b>Alet işler, el övünür</b><br />Atasözü<br />Bir kimse ne kadar usta olursa olsun gerekli araçları olmadan kusursuz iş yapamaz.<br /><br /><b>Az el aş kotarır, çok el iş kotarır</b><br />Atasözü<br />Yemek az kişiyle onun dışında kalan işler ise çok kişiyle daha çabuk yapılır.<br /><br /><b>Bin işçi, bir başçı</b><br />Atasözü<br />Her işe, baş olacak bir kimse gerekir.<br /><br /><b>(bir iş) gâvur orucu gibi uzamak</b><br />Deyim<br />Bir iş gereğinden çok sürmek, sürüncemede kalmak.<br /><br /><b>(bir iş) sallantıda kalmak</b><br />Deyim<br />Bir çözüme bağlanmamak.</p><p><br /><b>(bir iş) sekteye uğramak</b><br />Deyim<br />Kesilmek, kesintiye uğramak.</p><p><br /><b>(bir iş) sürüncemede kalmak</b><br />Deyim<br />Bir iş sonuçlanıncaya kadar boş yere gecikmek, uzamak, askıda kalmak, bir türlü sonuçlanamamak.<br /><br /><b>(bir işe) dört elle sarılmak (yapışmak)</b><br />Deyim<br />Bir işe büyük bir özen ve önem vererek girişmek: 'Sen bize dört elle sarılırsan zarar etmezsin.' -R. N. Güntekin.<br /><br /><b>(bir işi) dallandırıp budaklandırmak</b><br />Deyim<br />Bir işi, bir sorunu büyüterek karışık duruma getirmek.</p><p><br /><b>(bir işi) gözü yememek</b><br />Deyim<br />Bir işi yapacak güç ve yeteneği kendinde bulamamak.<br /><br /><b>(bir işi) tatlıya bağlamak</b><br />Deyim<br />Kavgalı bir işi gönül hoşluğuyla bitirmek: 'Hayır kardeşim, istemez diye tatlıya bağladım.' -O. V. Kanık.<br /><br /><b>(bir işi) yokuşa koşmak</b><br />Deyim<br />Bir konuda güçlük çıkarmak.<br /><br /><b>(bir işin) hamallığını etmek (yapmak)</b><br />Deyim<br />Bir işin önemsiz fakat ağır ve yorucu yükünü taşımak: 'Yok, yok! Sizi kimse hamallık etmeye bırakmaz.' -N. F. Kısakürek.<br /><br /><b>(bir işin) içinden çıkmak</b><br />Deyim<br />Karışık bir işin güçlüklerini yenebilmek, üstesinden gelmek: 'Pek cazip bir iş fakat çok paraya, çok vasıtaya ihtiyaç var. Bakalım bunun içinden nasıl çıkabileceğim?' -Y. K. Karaosmanoğlu.<br /><br /><b>(bir işin, şeyin) başına oturmak</b><br />Deyim<br />Bir işi yapmaya başlamak, işe koyulmak: 'Kendine güvenini tam bulduğu, oyununu yazabileceğine inandığı gün oturacaktı masanın başına.' -N. Cumalı.<br /><br /><b>(birini) işe koşmak</b><br />Deyim<br />Birine iş yaptırmak: 'Babama varıncaya kadar hepimizi işe koşuyor.' -R. N. Güntekin.<br /><br /><b>Bugünkü (akşamın) işini yarına (sabaha) bırakma (koyma)</b><br />Atasözü<br />Bugün yapılması gereken bir işin ertesi güne bırakılması iyi değildir.<br /><br /><b>Çocuğa iş buyuran, ardınca kendi gider</b><br />Atasözü<br />Çocuk kendisine ısmarlanan işi yapamayacağından işi buyuran kimsenin onun arkasından gitmesi gerekir.<br /><br /><b>El işi göz nuru</b><br />Deyim<br />El emeği göz nuru.<br /><br /><b>Erken kalktım işime, şeker kattım aşıma</b><br />Atasözü<br />İşine sabahleyin erken başlayan kimse başarı elde eder.<br /><br /><b>Eşeği düğüne çağırmışlar, 'ya odun eksik ya su demiş'</b><br />Atasözü<br />Bir işi yapmamak için bahane bulmayı anlatan bir söz.</p><p><br /><b>Eşeği düğüne çağırmışlar, 'ya su lazımdır ya odun' demiş</b><br />Atasözü<br />Bir işi yapmamak için bahane bulmayı anlatan bir söz.<br /><br /><b>Her yiğidin bir yoğurt yiyişi vardır</b><br />Atasözü<br />Herkesin kendine özgü bir çalışma yöntemi, bir iş yapma biçimi vardır.<br /><br /><b>Hile ile iş gören mihnet ile can verir</b><br />Atasözü<br />İşlerine hile karıştırıp başkalarını aldatan kişi son nefesini azap içinde verir.<br /><br /><b>İş ayağa düşmek</b><br />Deyim<br />İş, sorumsuz ve yetkisiz olanların elinde kalmak.<br /><br /><b>İş bilenin kılıç kuşanın</b><br />Atasözü<br />Her şey, onu gereği gibi kullanmasını bilene yakışır.<br /><br /><b>İş sarpa sarmak</b><br />Deyim<br />İş, içinden çıkılması zor bir duruma girmek.</p><p><br /><b>İş şirazesinden çıkmak</b><br />Deyim<br />Düzenini kaybetmek, çığırından çıkmak.<br /><br /><b>İşe yaramak</b><br />Deyim<br />Elverişli olmak: 'Bunları ezberledik de ne oldu? Hiç! Ne o günlerde işimize yaradı, ne de ondan sonra.' -M. Ş. Esendal.<br /><br /><b>İşin kolayına kaçmak</b><br />Deyim<br />Derinliğine araştırmadan basit olarak düşünmek, yüzeyde kalmak, tembellik etmek.<br /><br /><b>İşin kurdu</b><br />Deyim<br />Bir iş en ince ayrıntısını bilen, deneyimli, uzman (kimse).</p><p><br /><b>İşin kurdu olmak</b><br />Deyim<br />Belirli bir konuyla ilgili her şeyi bilmek, uzmanlaşmak: 'Şimdi yaşlandık, bu işlerin kurdu olduk.' -N. Meriç.<br /><br /><b>İşine hor bakan boynuna torba takar</b><br />Atasözü<br />İşini küçümseyen kişi istediği gibi para kazanamaz ve sonunda dilenci olur.<br /><br /><b>İşini kış tut da yaz çıkarsa bahtına</b><br />Atasözü<br />Başladığın bir işte her zaman güçlüklerle karşılaşacağını varsay ki sonunda hayal kırıklığına uğramayasın, iyi sonuçlar aldığında sevinesin.<br /><br /><b>İyi gitmeyince kişinin işi, muhallebi yerken kırılır dişi</b><br />Atasözü<br />İnsanın işi bir kez ters gitmeye görsün, en sıradan işlerinde bile tersliklerle karşılaşır.<br /><br /><b>İyi iş altı ayda çıkar</b><br />Atasözü<br />Doğru dürüst yapılması istenen iş uzun zaman ister.<br /><br /><b>Minareyi yaptırmayan yerden bitmiş sanır (bitti beller)</b><br />Atasözü<br />Önemli iş yapmamış olanlar, yapılmış önemli işleri kendiliğinden oluvermiş sanırlar.<br /><br /><b>Nasihat istersen tembele iş buyur</b><br />Atasözü<br />Tembel, kendisine buyurulan işi yapmamak için ya onun yapılmasına ihtiyaç bulunmadığını söyler ya da buyurulan biçimde değil, kendisinin işine gelen biçimde yapmayı önerir.<br /><br /><b>Paran gitti mi diye sormazlar, işin bitti mi diye sorarlar</b><br />Atasözü<br />Yapmak istediğin işi yapabildinse bu uğurda harcadığın paralara acıma çünkü para istediğin şeyi yapmak içindir.</p><p><br /><b>Paranın gittiğine bakma, işinin bittiğine bak</b><br />Atasözü<br />Yapmak istediğin işi yapabildinse bu uğurda harcadığın paralara acıma çünkü para istediğin şeyi yapmak içindir.<br /><br /><b>Perşembenin gelişi çarşambadan bellidir</b><br />Atasözü<br />Bir işin sonunun nasıl olacağı şimdiki gidişinden belli olur.<br /><br /><b>Terziye 'dinlen' demişler, ayağa kalkmış</b><br />Atasözü<br />Rahat görünen öyle işler vardır ki onunla uğraşanların dinlenmesi, kimileri için yorucu olan davranışlarla olur.<br /><br /><b>Toprağı işleyen, ekmeği dişler</b><br />Atasözü<br />İşini yapması gerektiği biçimde yapan kişi, çalışmasının verimlerinden yararlanır.<br /><br /><b>Üzerine ölü toprağı serpilmiş gibi</b><br />Deyim<br />Üstüne ölü toprağı serpilmiş gibi: 'Aldım eve getirdim kuşu. Başka zaman olsa üzerime ölü toprağı serpilmiş gibi uyurdum. Gece uyku girmedi gözüme. Arada bir uyanıp kuşa baktım.' -T. Dursun K.<br /><br /></p><p>Daha fazlası için</p><p><a href="https://www.muratoksuzer.com/2021/03/muhendis-ozlu-sozleri.html" target="_blank">Mühendis Özlü Sözleri tıklayın. </a></p><p><a href="https://www.muratoksuzer.com/2018/02/yazlmc-ozlu-sozleri.html" target="_blank">Yazılımcı Özlü Sözleri tıklayın.</a></p><p><br /><br /><br /><br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-44207541373962406352020-06-25T02:47:00.007-07:002021-04-04T00:42:10.584-07:0010 Maddede Yazılım Sektöründe İş Bulma Yahut Yeni Mezun Rehberi<p style="text-align: left;">Merhabalar. Yazılım sektörünün insan kaynağı hemen hemen tamamı şu üniversite bölümlerinden geliyor.</p><ul style="text-align: left;"><li>Bilgisayar Mühendisliği</li><li>Yazılım Mühendisliği</li><li>Yönetim Bilişim Sistemleri </li><li>Matematik</li><li>Elektrik Elektronik Mühendisliği</li><li>Makine ve Mekatronik Mühendisliği<br /></li></ul><p style="text-align: left;">Bu bölüm öğrencilerine ve yeni mezunlara bilişim dünyasında iş bulma üzerine naçizane tavsiyelerimi paylaşmak istiyorum. </p><p style="text-align: left;"></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgER9xsMBSEKZ6k5dXPhCovkNQaujwjz9f-eyM7e9bhTt3Mh2vPnVeXDfv2W2L3cG8kn7a4hn-L5PErZTAWSkdAUQWmjXjhTSsfk2-epOWwSxvtvo2oLMJL1EueNweguOojkgf-JJN3YD4/s602/mezun2.jpg" style="margin-left: auto; margin-right: auto;"><img alt="Bilgisayar Mühendisi Mezuniyet" border="0" data-original-height="403" data-original-width="602" height="268" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgER9xsMBSEKZ6k5dXPhCovkNQaujwjz9f-eyM7e9bhTt3Mh2vPnVeXDfv2W2L3cG8kn7a4hn-L5PErZTAWSkdAUQWmjXjhTSsfk2-epOWwSxvtvo2oLMJL1EueNweguOojkgf-JJN3YD4/w400-h268/mezun2.jpg" title="Bilgisayar Mühendisi Mezuniyet" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Bilgisayar Mühendisi Mezuniyet</td></tr></tbody></table><br /> <p style="text-align: left;"></p><p style="text-align: left;"></p><ol style="text-align: left;"><li>Elinizi kirletin. İlgi alanınız olan, çalışmak istediğiniz teknolojileri kullanarak ufak projeler yapıp GitHub'da vs paylaşın. </li><li>İngilizce öğrenin. En azından doküman okuma, Google'da İngilizce arama yapma, sorunlara çözüm bulma konusunda iyi olmanız gerekmekte. </li><li>Türkçe öğrenin. Dışardan bakıldığında daha çok makinelerle konuştuğumuz sanılabilir fakat işimizin büyük bir kısmı da müşterinin ne istediğini anlamaktır. Hatta müşteriden daha iyi anlayıp müşterinin beklentisinden daha iyi çözümler sunabilmektir. Bunun yolu da iyi iletişimden geçiyor. Kitap okumayı angaryadan saymayın. İletişim becerinize yaptığınız bir yatırım olarak görün ve kelime haznenizi genişletin. Yavuz Bülent Bakiler'in Sözün Doğrusu - 1 ve Sözün Doğrusu - 2 kitaplarını tavsiye ederim.<br /></li><li>Stajları dolu dolu geçirin. Mümkünse mezun olmadan öğrenci iken 3. veya 4. sınıfta iken bir firmada part time çalışın. Ücret önemli değil maksat tecrübe kazanıp heybenize birşeyler katmak.</li><li>Kariyer sitelerindeki iş ilanlarını inceleyerek piyasada hangi teknolojiler revaçta analizini yapın. Kendinizi hangi alanda geliştireceğinize karar vermede yardımcı olacaktır.</li><li>Öğrenci iken ödevlerinizi kendiniz yapın. İş hayatında tasklarınızı başkasına yaptıramayacaksınız.</li><li>Ücret beklentisi zor bir konu. Mezun olduktan 6 ay 1 sene geçmiş ve henüz işe başlayamamışsanız maaş beklentinizi esnetmeyi değerlendirebilirsiniz.</li><li>Ülkemizde yazılım sektörü daha çok üç büyük ilde dönüyor. İstanbul, Ankara, İzmir. İşi yanlış yerde arıyor olabilirsiniz.</li><li>Alanında uzman yazılımcıları / bilişimcileri sosyal mecralardan izleyin ne yaptıklarını takip edin. Bu kişiler arada iş ilanları da paylaşırlar.</li><li>Udemy veya benzeri kursları tamamlamak önemlidir ama o kadar da önemli değildir. İlk maddeyi hatırlatarak diyorum ki aldığınız eğitimi kullanarak bir proje yapın. Linkedin'de sertifika paylaşmak yerine GitHub reposu linki paylaşmak daha etkilidir. Ne demiş Linus Torvalds, "Talk is cheap. Show me the code!"</li></ol>BONUS: "İnci sancı mahsülüdür.". "Acı çekmeden öğrenemeyiz." Sabırlı olun. Sabırla ve azimle çalışmaya devam edin. Yazılım işi zordur ve bir yazılımcı kolay yetişmiyor. <p style="text-align: left;"></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-43950328507043561662020-05-24T00:46:00.009-07:002021-03-24T01:24:11.240-07:00Git Remote Repo Oluşturma ve Yereldeki Projeye Tanımlama<p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4IwxjXsBu5NBI33yxrEbDsIYeD-oj2xL3-Hr5ZGWbpg3HaqUykKihC5NlPi0bBwIw12izPfoDleryGtpvPSyacbbBZJsdrQtW2qAD_hhP-t9pmu4DocGOB-ZTO15IWf_zdv9u8c8deHg/s512/git.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="214" data-original-width="512" height="168" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4IwxjXsBu5NBI33yxrEbDsIYeD-oj2xL3-Hr5ZGWbpg3HaqUykKihC5NlPi0bBwIw12izPfoDleryGtpvPSyacbbBZJsdrQtW2qAD_hhP-t9pmu4DocGOB-ZTO15IWf_zdv9u8c8deHg/w400-h168/git.png" width="400" /></a></div><br /><p></p><p>Merhabalar. Bayram namazları kılınırken hocalar şu cümleyi kurarlar: "Efendim, senede 2 defa kılındığından unutulabiliyor. Bayram namazını şöyle şöyle kılacağız..." deyip bayram namazının nasıl kılınacağını tarif ederler. Benzer şekilde, her gün yeni bir projeye başlayıp yeni repolar oluşturmuyoruz. Bu nedenle </p><p><b>git commit -m "commit mesajı" </b></p><p>veya </p><p><b>git pull origin master </b></p><p>gibi hergün kullandığımız komutlar gibi ezbere bilemeyebiliyoruz, veya hatırlayamayabiliyoruz. Buraya hem kendime not olsun diye hem de hatırlama amacıyla uzak makinada bir git repo oluşturma ve kendi makinamızdaki projeyi bu repoya push'lama komutlarından bahsedeceğim.</p><p>Uzak makineye SSH ile bağlandığımızı veya bir şekilde Git Bash konsoluna ulaştığımızı varsayalım. Remote'da ortak git reposu olarak kullanılacak git reposu oluşturma ile yerelde proje içinde kullanacağımız git reposu oluşturma komutları farklıdır. </p><p>Öncelikle repomuzun bulunacağı klasörü ismi .git ile bitecek şekilde oluşturalım. <br /></p><p style="text-align: left;"><b>mkdir "yetAnotherAwesomeProject.git"</b><br /></p><p style="text-align: left;">Daha sonra oluşturduğumuz klasöre <b>cd </b>komutu ile girelim. </p><p style="text-align: left;"><b>cd yetAnotherAwesomeProject.git</b></p><pre style="text-align: left;"></pre><p style="text-align: left;">Şimdi<code class="hljs ada"></code> de git bare repomuzu oluşturacak komutu çalıştıralım.</p><p style="text-align: left;"><b>git init --bare</b><br /></p><p><code class="hljs ada"></code></p><pre><b><code class="hljs ada"></code></b></pre><p style="text-align: left;">Şimdi <code class="hljs ada"></code>bulunduğumuz klasörün tam sistem yolunu almak için <b>pwd </b>komutunu çalıştıralım.</p><p style="text-align: left;"><b>> pwd</b></p><p style="text-align: left;"><b>/home/username/yetAnotherAwesomeProject.git</b></p><p style="text-align: left;">Sistemimizin ip adresinin de 192.168.1.15 olduğunu ve linux kullanıcı adının username olduğunu varsayalım. </p><p style="text-align: left;">Şimdi yerel çalışma makinemize gelelim. Geliştirdiğimiz projenin içine konsoldan gidelim.</p><p style="text-align: left;"><b>cd yetAnotherAwesomeProject</b></p><p style="text-align: left;">Şimdi burada da çalışma için git reposu oluşturacağız.</p><p style="text-align: left;"><b>git init</b></p><p style="text-align: left;">Gereksiz dosyaların repoya gitmesini engellemek için bu klasörün içinde uygun bir <b>.gitignore</b> dosyası koymayı unutmayın. Şimdi de projemizi repoya commitleyelim.</p><p style="text-align: left;"><b>git add . </b></p><p style="text-align: left;">Git add nokta diyerek projemizdeki tüm dosyaları staged hale getirdik. Artık commitleyebiliriz.</p><p style="text-align: left;"><b>git commit -m "ilk commit mesajı" </b></p><p style="text-align: left;">Şimdi de remote repoyu tanımlama adımına geldik. SSH protokolüyle bağlanacağımızı varsayarak uzak reponun ip edresi ve linux kullanıcı adını kullanarak oluşturduğumuz URL'yi remote repo olarak tanımlayacağız.</p><p style="text-align: left;"><b>git remote add origin username@192.168.1.15:/home/username/yetAnotherAwesomeProject.git</b></p><p style="text-align: left;">Şimdi de yerelde commitlediğimiz tüm değişiklikleri remote repoya göndermek için push komutunu kullanacağız.</p><p style="text-align: left;"><b>git push origin master</b></p><p style="text-align: left;">Hepinize hayırlı bayramlar diliyorum :)<br /></p><p style="text-align: left;"><b> </b><br /></p><p style="text-align: left;"><b> </b></p><p style="text-align: left;"><b> </b><br /></p><p style="text-align: left;"><b> </b></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1182699704863936232.post-36082364495776773962020-04-22T07:29:00.005-07:002021-04-04T00:35:45.575-07:00Bilgisayar Mühendisi Ne Yapar? Çalışma Alanları Nelerdir?<p>Merhabalar. 2013 yılında ODTÜ Bilgisayar Mühendisliği'nden mezun olan biri olarak meslekle alakalı bilgi almak isteyen genç arkadaşlara tecrübelerimi paylaşmak istiyorum. </p><p>En temelde yazılım ve donanım olarak ayıracak olursak bu yazı daha çok yazılım alanındaki bilgisayar mühendisliği çalışma alanları hakkında olacak. </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGxxd7jd2UMhCVwUnDNhKgp_NdzbBzLt0W9hd5keKCEut283n0bl5MlL0q13lJV_BDlfErIZNZEzoFyynlhm0LpO4R962Kd2I0fWnnr7x9cJlU8PdIjPTr5TLXR7ai9uZka_KSPqIlpWY/s650/bilgisayar-muhendisligi-m.jpg" style="margin-left: auto; margin-right: auto;"><img alt="Bilgisayar Mühendisi ne yapar? Çalışma Alanları" border="0" data-original-height="407" data-original-width="650" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGxxd7jd2UMhCVwUnDNhKgp_NdzbBzLt0W9hd5keKCEut283n0bl5MlL0q13lJV_BDlfErIZNZEzoFyynlhm0LpO4R962Kd2I0fWnnr7x9cJlU8PdIjPTr5TLXR7ai9uZka_KSPqIlpWY/w400-h250/bilgisayar-muhendisligi-m.jpg" title="Bilgisayar Mühendisi ne yapar? Çalışma Alanları" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Bilgisayar Mühendisi ne yapar? Çalışma Alanları</td></tr></tbody></table><h3 style="text-align: left;">Neden Bilgisayar Mühendisliği?</h3><div>Çocukken oyuncakları bozma içini açma kurcalama merağım vardı. Oyuncak motorlarını söküp alma başka yerlerde kullanma gibi şeyler. Tabi bizim zamanımızda maker'lık deneyap atölyeleri gibi imkanlar yoktu. Şimdilerde çocuklar çok daha erken yazılımla tanışabiliyorlar. Bu elektronik merağı bilgisayar denilen aletle tanışınca bir başka boyut kazandı. Ekranda kullandığımız yazılımlara benzer işleri bizzat kendimizin de yapabileceği, elektronik mekanik aletlere komutlar verebilme fikri beni heyecanlandırmıştı. İlk kod denemelerimi lisedeyken bilgisayarıma kurduğum Dev-C++ üzerinde yapmıştım. İşe yarar birşey çıkmamıştı tabii ama en azından derleyici, kod, derleme, konsol uygulaması gibi kavramla ilk o zaman tanışmıştım.</div><div><br /></div><div></div><h3 style="text-align: left;">90'larda Çocuk Olmak</h3><h3 style="text-align: left;"><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCRCusNMTZ8JqRGetJcWPwIzpIHLZsEcLlBg5sYueK7F-tzuoyLSLaCYBrWZ4RiK1TWpE_GQT1uGX_eGa-bb2oZdG8U-LjP508hbMB1w6NfFYg32phsErPKz-99JibMjVUJAdQ4aR7dKk/s620/super-mario.jpg" style="margin-left: auto; margin-right: auto;"><img alt="Super Mario Bros" border="0" data-original-height="345" data-original-width="620" height="223" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCRCusNMTZ8JqRGetJcWPwIzpIHLZsEcLlBg5sYueK7F-tzuoyLSLaCYBrWZ4RiK1TWpE_GQT1uGX_eGa-bb2oZdG8U-LjP508hbMB1w6NfFYg32phsErPKz-99JibMjVUJAdQ4aR7dKk/w400-h223/super-mario.jpg" title="Super Mario Bros" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Super Mario Bros</td></tr></tbody></table></h3><p style="text-align: left;">Ayrıca <b>Super Mario</b> hatıramı da anlatmadan geçemeyeceğim. 90'larda çocuk olmak demek <b>Game Boy </b>ve <b>Atari </b>ile video oyunları oynamak demek. Biz de kuzenlerle beraber bayağı kalabalık bir çocuk grubu olarak bir atarinin önüne oturup saatlerce <b>Super Mario Bros</b>, <b>Tank 90</b> gibi oyunlar oynardık. </p><p style="text-align: left;"> </p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlWO3vdXA7A_c05JdSkyvwHCLvtlSTF9ZJcTUYuIKnpImdaSBwjj5h4D9Te2Zu5GmzX4C86yIzpTU9QoT5wCgyv_fG1hNg5iSe4tq1TnUWW4zLo6cLiwEYMRPu9NDzHuX8cwl4wL-WwVs/s1200/atari.jpg" style="margin-left: auto; margin-right: auto;"><img alt="Atari ve Kaset" border="0" data-original-height="800" data-original-width="1200" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlWO3vdXA7A_c05JdSkyvwHCLvtlSTF9ZJcTUYuIKnpImdaSBwjj5h4D9Te2Zu5GmzX4C86yIzpTU9QoT5wCgyv_fG1hNg5iSe4tq1TnUWW4zLo6cLiwEYMRPu9NDzHuX8cwl4wL-WwVs/w320-h213/atari.jpg" title="Atari ve Kaset" width="320" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Atari ve Kaset</td></tr></tbody></table><br /><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiffGz_b5JUrvgTk42z1Bn07pr-_BnrCw583t13wKC0gIiduy4pwALBrPls_UtQMpjIhbyXaTRCZIzwHwlw8Zjwxze9S3ssxvazyI-RaEmL61YaWFWK0ZR5ygcqi9ffHZPshE2iViM6XXA/s1430/el-atarisi-tetris-nostaljik-coklu-atari-el-atari-oyunu-9999-game-kk-65000-a7c368cf87cf4a0f89bdbba0c7effbb3.jpg" style="margin-left: auto; margin-right: auto;"><img alt="Gameboy 9999 in 1" border="0" data-original-height="1430" data-original-width="1300" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiffGz_b5JUrvgTk42z1Bn07pr-_BnrCw583t13wKC0gIiduy4pwALBrPls_UtQMpjIhbyXaTRCZIzwHwlw8Zjwxze9S3ssxvazyI-RaEmL61YaWFWK0ZR5ygcqi9ffHZPshE2iViM6XXA/w291-h320/el-atarisi-tetris-nostaljik-coklu-atari-el-atari-oyunu-9999-game-kk-65000-a7c368cf87cf4a0f89bdbba0c7effbb3.jpg" title="Gameboy 9999 in 1" width="291" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Gameboy 9999 in 1</td></tr></tbody></table><p style="text-align: left;"> Mario'da ustalaşan kişi de ölene kadar çok vakit geçerdi. Tabi kalabalık olunca ve sıranın ancak kişinin canı bitince başkasına geçmesi kuralı olunca sıra gelene kadar baya beklemek zorunda kalırdık. O sıralarda yapabilmeyi en çok istediğim şey o atari kasetinin içindeki Mario oyununu daha kısa sürecek hale getirmek veya komple kasetten silmek idi. Belki Mario olmazsa başka kısa süren oyunlar oynarlar ve sıra daha çabuk gelir diye. :)<br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBEkUzXmFGBoAaQpqU0dE4wT3Af-J-dFscFuvcVMaxhqV9s2F0Hp5MogyVBerQtWporks48tDOAHlzA90yZ-w4kmmUm9vGxvDTYZQFhp6rxrhLbqRlaI-BzjFLTcAUEZpfh-mS1XyoDdw/s237/atari-tank-1990.png" style="margin-left: auto; margin-right: auto;"><img alt="Tank 90" border="0" data-original-height="237" data-original-width="237" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBEkUzXmFGBoAaQpqU0dE4wT3Af-J-dFscFuvcVMaxhqV9s2F0Hp5MogyVBerQtWporks48tDOAHlzA90yZ-w4kmmUm9vGxvDTYZQFhp6rxrhLbqRlaI-BzjFLTcAUEZpfh-mS1XyoDdw/s16000/atari-tank-1990.png" title="Tank 90" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Tank 90<br /></td></tr></tbody></table><div> </div><div><h2 style="text-align: left;">Bilgisayar mühendisi ne yapar? </h2></div><div>Neyse, bu kadar nostalji yeter, konumuza dönelim. Bilgisayar mühendisliği çalışma alanlarını sektörel bazlı ve teknoloji bazlı olarak sınıflandırabiliriz.</div><div></div><div><h3 style="text-align: left;">Sektör Bazlı Sınıflandırma</h3><p style="text-align: left;">Tam şu anda içinde bulunduğunuz ortamda sağınıza solunuza bakın. İçinde bir şekilde yazılım koşan aygıtları saymaya çalışın. Evet yazılım artık heryanımızda. Bu nedenle bilgisayar mühendisleri de birçok farklı sektörde çalışabilmektedirler. Birkaçını sayacak olursak; </p><ul style="text-align: left;"><li>Savunma sanayi</li><li>Otomotiv <br /></li><li>Sağlık</li><li>Oyun / eğlence</li><li>Eğitim</li><li>Hizmet Sektörü </li><li>Finans</li></ul><p>ve daha sayamadığım niceleri. Bu kadar geniş çalışma alanı olan başka çok az meslek grubu vardır sanıyorum. İşin ilginç tarafı, iş değişiklikleri nedeniyle bir yıl sağlık sektöründe çalışan yazılımcı, sonraki yıl oyun sektörüne, sonraki işinde savunma sanayiine geçiş yapabilmektedir. Bunun nedeni kullanılan teknelojilerin çok farklı problemlere çözüm üretmek için kullanılabilmesi. Örneğin, oyun sektöründe çalışırken oyun motorları üzerinde uzmanlaşan bir yazılımcı, savunma snayiinde askeri simülasyon üreten firmalara çok rahat geçiş yapabilmektedirler. Veya öğrendiği javascript ile yemek siparişi sitesi kodlayan bir yazılımcı sonraki işinde hastane bilgi sistemi kodlarken bulabilir kendini.<br /></p><h3 style="text-align: left;">Teknoloji Bazlı Sınıflandırma</h3><p>Bilgisayar mühendisi ne yapar sorusuna cevap arıyoruz. Bunun için çalışma alanlarını kategorize ederken kullanılan teknolojilere göre de bir ayrım yapabiliriz. Bir bilgisayar mühendisi<br /></p><ul style="text-align: left;"><li>Masaüstü yazılım geliştiricisi<br /></li><li>Web uygulama geliştiricisi</li><li>Mobil uygulama geliştiricisi</li><li>Gömülü yazılım geliştiricisi</li></ul><p>olarak çalışabilmektedir. Masaüstü yazılımlarla, üzerinde koşulan bilgisayarın tüm CPU, Ram gibi kaynaklarını sonuna kadar kullanabilirsiniz. Bir web uygulaması üzerinde çalışıyorken, milyonlarca insana hizmet verecek bir sayfa geliştiriyor olabilirsiniz. Bir gömülü yazılım geliştirerek düşman hanelerine bir mızrak gibi girecek füzeyi kontrol ediyor olabilirsiniz. Bir mobil app geliştirerek "tanesini 1 dolardan satsam, 1 milyon indirilse, köşeyi döndük demektir. Yırttık abicim!!" hayalleri kurabilirsiniz.</p><h3 style="text-align: left;">Bilgisayar Bilimi</h3><p>Şimdiye kadar geliştiricilik alanından örnekler verdik. İşin bir de bilim tarafı var. Yapay zeka, makine öğrenmesi, big data, IoT (internet of things), robotik, bilgisayarlı görü (computer vision) vs... Bilgisayar bilimi hala çok genç ve çok hızlı bir şekilde gelişmeye devam ediyor. Akademik sahada da kariyer olanaklarını değerlendirebilirsiniz.</p><h3 style="text-align: left;">Bilgisayar Mühendisi Ne Kadar Maaş Alır?</h3><h3 style="text-align: left;"> <table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTsmHIWLAbeWz90nVvSzn5o_ppsAGECsxa8ah_0e5gIWMOo-9SFVPKy0g9VZSRMpto9cRMtl_SWPJ2MsldAv95ZjJi9a1FlhqD4zHdwvDNa-bO47yMN16fZDMHk1ebJjAlnTOdQSxoJss/s598/para.Jpeg" style="margin-left: auto; margin-right: auto;"><img alt="Bilgisayar Mühendisi Maaşı" border="0" data-original-height="362" data-original-width="598" height="194" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTsmHIWLAbeWz90nVvSzn5o_ppsAGECsxa8ah_0e5gIWMOo-9SFVPKy0g9VZSRMpto9cRMtl_SWPJ2MsldAv95ZjJi9a1FlhqD4zHdwvDNa-bO47yMN16fZDMHk1ebJjAlnTOdQSxoJss/w320-h194/para.Jpeg" title="Bilgisayar Mühendisi Maaşı" width="320" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Bilgisayar Mühendisi Maaşı<br /></td></tr></tbody></table></h3><p>Son zamanlarda yazılımcılar arasında maaşlar konusunda anketler yapılıyor ve yayınlanıyor. Bu sorunun cevabı için oralara yönlendirebilirim. </p><p class="fs df ft av cu fu fv fw fx fy fz ga gb gc gd ge gf gg gh gi gj gk gl gm gn go gp" id="4507" style="text-align: left;"><a href="https://medium.com/@oncekiyazilimci/yaz%C4%B1l%C4%B1mc%C4%B1-maa%C5%9Flar%C4%B1-2020-74c567acd47e" target="_blank">Yazılımcı Maaşları | 2020</a></p><p class="fs df ft av cu fu fv fw fx fy fz ga gb gc gd ge gf gg gh gi gj gk gl gm gn go gp" id="4507" style="text-align: left;"><a href="https://medium.com/@oncekiyazilimci/yaz%C4%B1l%C4%B1mc%C4%B1-maa%C5%9Flar%C4%B1-2019-f0e535d736a3" target="_blank">Yazılımcı Maaşları | 2019</a></p><h3 class="fs df ft av cu fu fv fw fx fy fz ga gb gc gd ge gf gg gh gi gj gk gl gm gn go gp" id="4507" style="text-align: left;">Sonuç / Tavsiyeler</h3><p class="fs df ft av cu fu fv fw fx fy fz ga gb gc gd ge gf gg gh gi gj gk gl gm gn go gp" id="4507" style="text-align: left;">Meslek seçerken ilgi ve yeteneğinizi göz önünde bulundurun. Sadece parası iyi diye meslek seçmek mutsuz bir hayat yaşamanıza sebebiyet verebilir. Yazılım işi analitik düşünme, sorunlara çözüm üretebilme, zorlu problemlere sabırla cevap arama, hemen pes etmeme gibi alanlarda iyi olmanızı gerektirir. Ama herşeyden çok sevmeniz gerekir. Sadece yazılımda değil, ne iş olursa olsun, işlerini sevenlerin daha başarılı olduğunu gözlemlemişsinizdir. Üniversite tercih listesi hazırlamaya çalışan arkadaşlara bir nebze de olsa yardımcı olduysak bu yazı amacına ulaşmış demektir. Üniversite sınavına girecek tüm arkadaşlara başarılar diliyorum. <br /></p></div><div> </div><br /><div><br /></div>Unknownnoreply@blogger.com1